Fixed boxed boolean handling

This commit is contained in:
Tagir Valeev
2018-09-17 16:38:14 +07:00
parent 556f60bed4
commit 462630c9b5
3 changed files with 14 additions and 1 deletions
@@ -911,7 +911,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
return true;
}
return applyRelation(unboxedLeft, unboxedRight, negated) &&
checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, negated);
((negated && !isNotNull(dfaLeft)) || checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, negated));
}
private boolean checkCompareWithBooleanLiteral(DfaValue dfaLeft, DfaValue dfaRight, boolean negated) {
@@ -0,0 +1,12 @@
import org.jetbrains.annotations.*;
class X {
native @Nullable Boolean readSomething();
void test() {
final Boolean x = readSomething();
if(x == Boolean.TRUE) {}
else if(x == Boolean.FALSE || x == null) {}
else {}
}
}
@@ -648,4 +648,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
public void testSameArguments() { doTest(); }
public void testMaxLoop() { doTest(); }
public void testExplicitBoxing() { doTest(); }
public void testBoxedBoolean() { doTest(); }
}