As reported here:
https://mail.openjdk.org/pipermail/amber-spec-experts/2022-July/003479.html
Consider this code:
---
public class Main {
public static void main(String[] args) {
Integer x = null;
switch (x) {
case Integer i -> System.out.println(i);
case null -> System.out.println("null is supplied!");
}
}
}
---
This should compile, but does not:
---
$ javac --enable-preview -source 20 /tmp/Main.java
/tmp/Main.java:6: error: this case label is dominated by a preceding case label
case null -> System.out.println("null is supplied!");
^
Note: /tmp/Main.java uses preview features of Java SE 20.
Note: Recompile with -Xlint:preview for details.
1 error
---
https://mail.openjdk.org/pipermail/amber-spec-experts/2022-July/003479.html
Consider this code:
---
public class Main {
public static void main(String[] args) {
Integer x = null;
switch (x) {
case Integer i -> System.out.println(i);
case null -> System.out.println("null is supplied!");
}
}
}
---
This should compile, but does not:
---
$ javac --enable-preview -source 20 /tmp/Main.java
/tmp/Main.java:6: error: this case label is dominated by a preceding case label
case null -> System.out.println("null is supplied!");
^
Note: /tmp/Main.java uses preview features of Java SE 20.
Note: Recompile with -Xlint:preview for details.
1 error
---