2019-06-10 03:09:52 +00:00
|
|
|
/**
|
|
|
|
* @test /nodynamiccopyright/
|
|
|
|
* @summary Verify that definite assignment works (illegal code)
|
2019-11-12 06:32:13 +00:00
|
|
|
* @compile/fail/ref=DefiniteAssignment2.out -XDrawDiagnostics DefiniteAssignment2.java
|
2019-06-10 03:09:52 +00:00
|
|
|
*/
|
|
|
|
public class DefiniteAssignment2 {
|
|
|
|
|
2023-01-17 04:43:40 +00:00
|
|
|
public static void meth() {
|
2019-06-10 03:09:52 +00:00
|
|
|
int a = 0;
|
|
|
|
E e = E.A;
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(a) {
|
|
|
|
case 0: break;
|
|
|
|
default: x = 1; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(a) {
|
|
|
|
case 0 -> {}
|
|
|
|
default -> x = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(a) {
|
|
|
|
case 0: x = 0; break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(e) {
|
|
|
|
case A, B, C -> x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(e) {
|
|
|
|
case A, B, C -> { x = 0; }
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
switch(e) {
|
|
|
|
case A, B -> { x = 0; }
|
|
|
|
case C -> throw new IllegalStateException();
|
|
|
|
}
|
|
|
|
|
|
|
|
System.err.println(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum E {
|
|
|
|
A, B, C;
|
|
|
|
}
|
|
|
|
}
|