Reorganize AST related to pattern matching for switch

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 19
    • Affects Version/s: 19
    • Component/s: tools
    • None
    • b26

      Under JEP 427, case label elements may be: a) expressions; b) patterns; c) the default. Currently, this is modeled in the AST in a way where all expressions and patterns extend CaseLabelTree.

      When guarded patterns were removed in favor of guards on pattern case label element, it was necessary to augment all patterns with a guard, which is only used when the pattern is used as a case label element. This feels somewhat odd.

      It might be better to use a layer of indirection - the CaseLabelTree would only have three subtypes: ExpressionCaseLabelTree, which would contain ExpressionTree as a subnode; PatternCaseLabelTree, which would contain PatternTree and a guard (ExpressionTree) as subnodes; and the DefaultCaseLabelTree for the default clause.

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: