diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index e1ec00c16c91..8b2beae6d5d9 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -705,7 +705,10 @@ public class DfaMemoryStateImpl implements DfaMemoryState { } DfaBoxedValue.Factory boxedFactory = myFactory.getBoxedFactory(); - return applyRelation(boxedFactory.createUnboxed(dfaLeft), boxedFactory.createUnboxed(dfaRight), negated); + DfaValue unboxedLeft = boxedFactory.createUnboxed(dfaLeft); + DfaValue unboxedRight = boxedFactory.createUnboxed(dfaRight); + return applyRelation(unboxedLeft, unboxedRight, negated) && + checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, negated); } private boolean checkCompareWithBooleanLiteral(DfaValue dfaLeft, DfaValue dfaRight, boolean negated) { @@ -716,6 +719,9 @@ public class DfaMemoryStateImpl implements DfaMemoryState { if (!applyRelation(dfaLeft, negVal, !negated)) { return false; } + if (!applyRelation(dfaLeft.createNegated(), negVal, negated)) { + return false; + } } } return true; diff --git a/java/java-tests/testData/inspection/dataFlow/boxingBoolean/expected.xml b/java/java-tests/testData/inspection/dataFlow/boxingBoolean/expected.xml index e04ae9dabc10..f0b6066c0c00 100644 --- a/java/java-tests/testData/inspection/dataFlow/boxingBoolean/expected.xml +++ b/java/java-tests/testData/inspection/dataFlow/boxingBoolean/expected.xml @@ -35,5 +35,11 @@ 51 Condition <code>o</code> at the left side of assignment expression is always <code>false</code>. Can be simplified. + + + Test.java + 62 + Condition <code>o</code> is always <code>true</code> + diff --git a/java/java-tests/testData/inspection/dataFlow/boxingBoolean/src/Test.java b/java/java-tests/testData/inspection/dataFlow/boxingBoolean/src/Test.java index 15e38edae430..635c2922e449 100644 --- a/java/java-tests/testData/inspection/dataFlow/boxingBoolean/src/Test.java +++ b/java/java-tests/testData/inspection/dataFlow/boxingBoolean/src/Test.java @@ -52,4 +52,14 @@ public class S { if (o) { } } + + public void flushOriginal(boolean b){ + boolean o; + { + Boolean c = Boolean.FALSE; + o = !c; + } + if (o) { + } + } }