2018-12-03 09:37:36 +00:00
|
|
|
/**
|
|
|
|
* @test /nodynamiccopyright/
|
|
|
|
* @bug 8214031
|
|
|
|
* @summary Verify that definite assignment when true works (illegal code)
|
2018-12-13 18:06:11 +00:00
|
|
|
* @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source 13 -XDrawDiagnostics DefiniteAssignment2.java
|
2018-12-03 09:37:36 +00:00
|
|
|
*/
|
|
|
|
public class DefiniteAssignment2 {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
int a = 0;
|
|
|
|
boolean b = true;
|
|
|
|
boolean t;
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (b && switch(a) {
|
|
|
|
case 0: break (x = 1) == 1 || true;
|
|
|
|
default: break false;
|
|
|
|
}) || x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: break (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) || x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: x = 1; break true;
|
|
|
|
case 1: break (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) || x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: break true;
|
|
|
|
case 1: break (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) && x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: break false;
|
|
|
|
case 1: break isTrue() || (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) && x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: break false;
|
|
|
|
case 1: break isTrue() ? true : (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) && x == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
final int x;
|
|
|
|
|
|
|
|
t = (switch(a) {
|
|
|
|
case 0: break false;
|
|
|
|
case 1: break isTrue() ? true : (x = 1) == 1;
|
|
|
|
default: break false;
|
|
|
|
}) && (x = 1) == 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean isTrue() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|