Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8287236

Reorganize AST related to pattern matching for switch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 19
    • 19
    • 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.

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

              Created:
              Updated:
              Resolved: