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 56bf0f301195..d7c7c586890a 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 @@ -702,16 +702,16 @@ public class DfaMemoryStateImpl implements DfaMemoryState { if (!TypeConversionUtil.isPrimitiveWrapper(type)) { return true; } - if (negated && !(unwrap(dfaRight) instanceof DfaConstValue)) { - // from the fact (wrappers are not the same) does not follow (unboxed values are not equals) + if (negated) { + // from the fact "wrappers are not the same" it does not follow that "unboxed values are not equal" return true; } DfaBoxedValue.Factory boxedFactory = myFactory.getBoxedFactory(); DfaValue unboxedLeft = boxedFactory.createUnboxed(dfaLeft); DfaValue unboxedRight = boxedFactory.createUnboxed(dfaRight); - return applyRelation(unboxedLeft, unboxedRight, negated) && - checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, negated); + return applyRelation(unboxedLeft, unboxedRight, false) && + checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, false); } private boolean checkCompareWithBooleanLiteral(DfaValue dfaLeft, DfaValue dfaRight, boolean negated) { diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableBoolean.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableBoolean.java index 36756339d51d..e6a8445a55a1 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/NullableBoolean.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableBoolean.java @@ -1,5 +1,6 @@ import org.jetbrains.annotations.Nullable; +import java.lang.Boolean; import java.util.List; class Foo { @@ -20,4 +21,12 @@ class Foo { } } + public static void main3(Boolean b) { + if (b == Boolean.FALSE) { + System.out.println(); + } else if (b == Boolean.TRUE) { + System.out.println(); + } + } + } \ No newline at end of file