mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] IDEA-354336 Java DFA fails to report nullable var passed to notnull arg after instanceof
GitOrigin-RevId: 2fada677a054fbd049e12e9b585a5f08711a5b26
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c05ea7c662
commit
3b45af56a7
+22
@@ -0,0 +1,22 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Main {
|
||||
Record foo() {
|
||||
PsiFile file = fooBar();
|
||||
if (file instanceof PsiCompiledFile compiledFile) {
|
||||
return new Record(compiledFile);
|
||||
}
|
||||
return new Record(<warning descr="Argument 'file' might be null">file</warning>);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiFile fooBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
interface PsiFile {}
|
||||
interface PsiCompiledFile extends PsiFile {}
|
||||
|
||||
private record Record(@NotNull PsiFile file) {}
|
||||
}
|
||||
@@ -130,4 +130,6 @@ public class DataFlowInspection21Test extends DataFlowInspectionTestCase {
|
||||
|
||||
public void testArrayElementWrappedInPureMethod() { doTest(); }
|
||||
public void testArrayAddedIntoCollection() { doTest(); }
|
||||
|
||||
public void testInstanceOfPatternAffectNullity() { doTest(); }
|
||||
}
|
||||
+1
-1
@@ -1290,7 +1290,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
type = type.fromRelation(RelationType.EQ);
|
||||
for (DfaVariableValue value : eqClass.asList()) {
|
||||
if (value != dfaVar) {
|
||||
recordVariableType(value, type.meet(value.getInherentType()));
|
||||
recordVariableType(value, type.meet(getDfType(value)));
|
||||
if (!updateQualifierOnEquality(value, value)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user