Open srikanth-sankaran opened 1 day ago
Better test case:
public class X {
public static void main(String [] args) {
switch (10) {
case switch (10) { default -> 10; } :
System.out.println("Should not compile as per 15.29 & 14.11.1");
}
}
}
@jarthana @stephan-herrmann - FYI - My reading of 15.29 & 14.11.1 says this program should be rejected, but javac 23 compiles it. We don't: case expressions must be constant expressions
Brought forward from https://bugs.eclipse.org/bugs/show_bug.cgi?id=565907
Follow up from bug 565844 comment 6:
consider the code: case switch (2) {default ->1} ->
This has a constant value and the compiler should not flag an error.