mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dfa: correctly handle ""== Boolean.TRUE/FALSE"
This commit is contained in:
+4
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user