[java-dfa] Fix stack flushing

GitOrigin-RevId: e953c3be78bcc3e43fcc9777d8573ff3650638e4
This commit is contained in:
Tagir Valeev
2021-05-11 12:00:09 +00:00
committed by intellij-monorepo-bot
parent c242617aff
commit cb6448267d
3 changed files with 14 additions and 2 deletions
@@ -1129,8 +1129,9 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
doFlush(value, true);
}
myStack.replaceAll(val -> {
DfType type = val.getDfType();
if (ContainerUtil.or(type.getDerivedVariables(), dv -> !dv.isStable() && qualifierStatusMap.shouldFlush(val, dv.isCall()))) {
DfType type = getDfType(val);
if (ContainerUtil.or(type.getDerivedVariables(), dv -> type.getDerivedValue(dv) != DfType.TOP &&
!dv.isStable() && qualifierStatusMap.shouldFlush(val, dv.isCall()))) {
return myFactory.fromDfType(type.getBasicType());
}
return val;
@@ -0,0 +1,10 @@
import org.jetbrains.annotations.*;
import java.util.List;
public class NullableCallWithPrecalculatedValueAndSpecialField {
@NotNull List<String> test() {
return <warning descr="Expression 'getNulableValue()' might evaluate to null but is returned by the method declared as @NotNull">getNulableValue()</warning>;
}
native @Nullable List<String> getNulableValue();
}
@@ -702,4 +702,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
public void testGetterNullityAfterCheck() { doTest(); }
public void testInferenceNullityMismatch() { doTestWith(insp -> insp.SUGGEST_NULLABLE_ANNOTATIONS = false); }
public void testFieldInInstanceInitializer() { doTest(); }
public void testNullableCallWithPrecalculatedValueAndSpecialField() { doTest(); }
}