mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Fix ephemeral states on comparison
GitOrigin-RevId: cd7fde86062bcda7145dae7b98c661a64fbccb9d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca58327e44
commit
ad22cd9a74
+7
-7
@@ -715,6 +715,11 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
if (DfaTypeValue.isUnknown(dfaLeft) || DfaTypeValue.isUnknown(dfaRight)) return true;
|
||||
|
||||
if (relationType == RelationType.EQ && dfaLeft instanceof DfaVariableValue && dfaRight instanceof DfaVariableValue) {
|
||||
checkEphemeral(dfaLeft, dfaRight);
|
||||
checkEphemeral(dfaRight, dfaLeft);
|
||||
}
|
||||
|
||||
DfType leftType = getDfType(dfaLeft);
|
||||
DfType rightType = getDfType(dfaRight);
|
||||
|
||||
@@ -877,13 +882,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == RelationType.EQ) {
|
||||
if (dfaLeft instanceof DfaVariableValue && dfaRight instanceof DfaVariableValue) {
|
||||
checkEphemeral(dfaLeft, dfaRight);
|
||||
checkEphemeral(dfaRight, dfaLeft);
|
||||
}
|
||||
if (!applySpecialFieldEquivalence(dfaLeft, dfaRight)) return false;
|
||||
}
|
||||
if (type == RelationType.EQ && !applySpecialFieldEquivalence(dfaLeft, dfaRight)) return false;
|
||||
|
||||
if (dfaLeft instanceof DfaVariableValue && dfaRight instanceof DfaVariableValue && !isNegated) {
|
||||
if (!equalizeTypesOnGetClass((DfaVariableValue)dfaLeft, (DfaVariableValue)dfaRight)) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.Set;
|
||||
|
||||
public class UnknownComparedToNullable {
|
||||
native Object getObject(int x);
|
||||
|
||||
void test(int val) {
|
||||
Object s1 = val < 0 ? null : getObject(val * 2);
|
||||
Object s2 = getObject(val);
|
||||
if (s1 != s2) {}
|
||||
System.out.println(s2.hashCode());
|
||||
}
|
||||
}
|
||||
@@ -696,4 +696,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testCollectionViewsSize() { doTest(); }
|
||||
public void testFlushedNullableOnUnknownCall() { doTest(); }
|
||||
public void testBoxedDivisionComparison() { doTest(); }
|
||||
public void testUnknownComparedToNullable() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user