mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unknown variables should not be nullable-enabled after instanceof
This commit is contained in:
+4
@@ -585,9 +585,13 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
}
|
||||
return applyCondition(compareToNull(dfaVar, false));
|
||||
}
|
||||
boolean wasUnknown = getVariableState(dfaVar).getNullability() == Nullness.UNKNOWN;
|
||||
if (applyCondition(compareToNull(dfaVar, true))) {
|
||||
DfaVariableState newState = getVariableState(dfaVar).withInstanceofValue((DfaTypeValue)dfaRight);
|
||||
if (newState != null) {
|
||||
if (wasUnknown) {
|
||||
newState = newState.withNullability(Nullness.UNKNOWN);
|
||||
}
|
||||
setVariableState(dfaVar, newState);
|
||||
return true;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Some {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String) {
|
||||
|
||||
}
|
||||
o.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testVariablesDiverge() { doTest(); }
|
||||
public void testDontForgetInstanceofInfoWhenMerging() { doTest(); }
|
||||
public void testDontMakeNullableAfterInstanceof() { doTest(); }
|
||||
|
||||
public void _testNullCheckBeforeInstanceof() { doTest(); } // http://youtrack.jetbrains.com/issue/IDEA-113220
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user