-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
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)
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)