As reported here:
http://mail.openjdk.java.net/pipermail/amber-dev/2019-March/004204.html
javac fails to compile this code:
---
enum MyEnum {
X, Y;
public static void main(String[] args) {
MyEnum myEnum = MyEnum.X;
int o;
var f = switch(myEnum) {
case X -> o = 5;
case Y -> o = 10;
// automatic exception
};
System.out.println(o);
}
}
---
---
$ javac --enable-preview --source 13 /tmp/MyEnum.java
/tmp/MyEnum.java:12: error: variable o might not have been initialized
System.out.println(o);
^
Note: /tmp/MyEnum.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
1 error
---
http://mail.openjdk.java.net/pipermail/amber-dev/2019-March/004204.html
javac fails to compile this code:
---
enum MyEnum {
X, Y;
public static void main(String[] args) {
MyEnum myEnum = MyEnum.X;
int o;
var f = switch(myEnum) {
case X -> o = 5;
case Y -> o = 10;
// automatic exception
};
System.out.println(o);
}
}
---
---
$ javac --enable-preview --source 13 /tmp/MyEnum.java
/tmp/MyEnum.java:12: error: variable o might not have been initialized
System.out.println(o);
^
Note: /tmp/MyEnum.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
1 error
---