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

14.11.1 Small slip in fall-through conditions regarding pattern variables in switch blocks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • specification

      Currently JLS 14.11.1 gives an error condition:

      It is a compile-time error if, in a switch block that consists of switch labeled statement groups, a statement is labeled with a case pattern that declares one or more pattern variables, and either: ...

      Clearly, it was intended that the condition was not restricted to the pattern in the case label, but also to include any guard associated with the label. In other words it should read:

      It is a compile-time error if, in a switch block that consists of switch labeled statement groups, a statement is labeled with a case _label_ that declares one or more pattern variables, and either: ...

      (Along with a reference to 6.3.3 where this is defined)

            gbierman Gavin Bierman
            gbierman Gavin Bierman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: