dfa: correctly handle ""== Boolean.TRUE/FALSE"

This commit is contained in:
peter
2015-04-24 19:16:44 +02:00
parent af2475a3c9
commit c577be8f4f
2 changed files with 13 additions and 4 deletions
@@ -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) {
@@ -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();
}
}
}