DFA: instanceof for unknown variable still may perform declared type check

Fixes IDEA-191374 DFA: "condition `x instanceof X` can be replaced with a null check" is not reported
This commit is contained in:
Tagir Valeev
2018-05-07 13:01:45 +07:00
parent 28b1de4b70
commit 24cde212c9
3 changed files with 20 additions and 1 deletions
@@ -0,0 +1,12 @@
// IDEA-191374
class B {}
class A {
private B b = new B();
void foo() {
String s = b != null ? b.toString() : ""; //comment this line and the error will appear
if (<warning descr="Condition 'b instanceof B' is redundant and can be replaced with a null check">b instanceof B</warning>) { // no error reported here
System.out.println(b);
}
}
}