dfa: handle in a special way only getX() != null comparisons (IDEA-141823)

This commit is contained in:
peter
2015-06-24 14:29:34 +02:00
parent ec12eb6e60
commit 02fc02798f
2 changed files with 22 additions and 2 deletions
@@ -650,13 +650,15 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
return true;
}
final boolean containsCalls = dfaLeft instanceof DfaVariableValue && ((DfaVariableValue)dfaLeft).containsCalls();
// track "x" property state only inside "if (getX() != null) ..."
if (dfaLeft instanceof DfaVariableValue && ((DfaVariableValue)dfaLeft).containsCalls() && (!isNull(dfaRight) || !isNegated)) {
if (containsCalls && !isNotNull(dfaLeft) && isNull(dfaRight) && !isNegated) {
return true;
}
if (dfaLeft == dfaRight) {
return !isNegated;
return containsCalls || !isNegated;
}
if (isNull(dfaLeft) && isNotNull(dfaRight) || isNull(dfaRight) && isNotNull(dfaLeft)) {
@@ -41,3 +41,21 @@ class Foo {
}
class Test {
@NotNull
String getName() {
return "";
}
@Nullable
@Contract("!null -> !null")
String convert(@Nullable String name) {
return name;
}
@NotNull
String test() {
return convert(getName());
}
}