mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaMemoryStateImpl#applyUnboxedRelation: NPE fixed on erroneous code (EA-137969)
This commit is contained in:
+1
-1
@@ -1137,7 +1137,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
DfaConstValue leftConst = getConstantValue(unboxedLeft);
|
||||
DfaConstValue rightConst = getConstantValue(unboxedRight);
|
||||
if (leftConst != null && rightConst != null) {
|
||||
return leftConst.getValue().equals(rightConst.getValue()) != negated;
|
||||
return Objects.equals(leftConst.getValue(), rightConst.getValue()) != negated;
|
||||
}
|
||||
if (negated && (PsiType.FLOAT.equals(unboxedLeft.getType()) || PsiType.DOUBLE.equals(unboxedLeft.getType()))) {
|
||||
// If floating point wrappers are not equal, unboxed versions could still be equal if they are 0.0 and -0.0
|
||||
|
||||
+6
-7
@@ -61,13 +61,12 @@ public class DfaBinOpValue extends DfaValue {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String delimiter;
|
||||
if (myOp == BinOp.PLUS && myRight instanceof DfaConstValue &&
|
||||
((DfaConstValue)myRight).getValue() instanceof Long &&
|
||||
(Long)((DfaConstValue)myRight).getValue() < 0) {
|
||||
delimiter = "";
|
||||
} else {
|
||||
delimiter = myOp.toString();
|
||||
String delimiter = myOp.toString();
|
||||
if (myOp == BinOp.PLUS && myRight instanceof DfaConstValue) {
|
||||
Object value = ((DfaConstValue)myRight).getValue();
|
||||
if (value instanceof Long && (Long)value < 0) {
|
||||
delimiter = "";
|
||||
}
|
||||
}
|
||||
return myLeft + delimiter + myRight;
|
||||
}
|
||||
|
||||
+1
@@ -175,6 +175,7 @@ public class DfaConstValue extends DfaValue {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@@ -16,4 +16,9 @@ class Testcase {
|
||||
}
|
||||
}
|
||||
|
||||
void test() {
|
||||
<error descr="Incompatible types. Found: 'null', required: 'int'">int x = null;</error>
|
||||
Integer boxed = x;
|
||||
if (<warning descr="Condition 'boxed == 5' is always 'false'">boxed == 5</warning>) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user