diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java index 36449128b494..96102b53f5d4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java @@ -70,7 +70,9 @@ public class StandardInstructionVisitor extends InstructionVisitor { DfaValueFactory factory = runner.getFactory(); if (dfaSource instanceof DfaVariableValue && factory.getVarFactory().getAllQualifiedBy(var).contains(dfaSource)) { - dfaSource = factory.createTypeValue(((DfaVariableValue)dfaSource).getVariableType(), ((DfaVariableValue)dfaSource).getInherentNullability()); + Nullness nullability = memState.isNotNull(dfaSource) ? Nullness.NOT_NULL + : ((DfaVariableValue)dfaSource).getInherentNullability(); + dfaSource = factory.createTypeValue(((DfaVariableValue)dfaSource).getVariableType(), nullability); } if (var.getInherentNullability() == Nullness.NOT_NULL) { diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/RootThrowableCause.java b/java/java-tests/testData/inspection/dataFlow/fixture/RootThrowableCause.java index 6086c92b40d4..1197fe817e8e 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/RootThrowableCause.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/RootThrowableCause.java @@ -1,3 +1,6 @@ +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; + class Doo { void foo(Throwable e) { @@ -9,4 +12,18 @@ class Doo { } } +} + +abstract class Test04 { + @Nullable + @Contract(pure = true) + abstract Test04 getParent(); + + Test04 getTopParent() { + Test04 top = this; + while (top.getParent() != null) { + top = top.getParent(); + } + return top; + } } \ No newline at end of file