Java: Update variable nullability only when DFA is completed successfully (IDEA-188416)

This commit is contained in:
Pavel Dolgov
2018-05-18 13:17:08 +03:00
parent 7961637e71
commit ea0b3c7fa9
6 changed files with 87 additions and 5 deletions

View File

@@ -0,0 +1,29 @@
import org.jetbrains.annotations.NotNull;
class TooComplexCode {
static class X { @NotNull X get() { return this; }}
static class A extends X { @NotNull X get() { return new B(); }}
static class B extends X { @NotNull X get() { return new C(); }}
static class C extends X { @NotNull X get() { return new A(); }}
void tooComplex(@NotNull X x) {
if (x instanceof A) {
<selection>X y = x.get();</selection>
if (y instanceof A) {
System.out.println("A A "+x+' '+y);
}
if (y instanceof B) {
System.out.println("A B "+x+' '+y);
}
}
if (x instanceof B) {
X y = x.get();
if (y instanceof A) {
System.out.println("B A "+x+' '+y);
}
if (y instanceof B) {
System.out.println("B B "+x+' '+y);
}
}
}
}