Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/NullWarningAfterInstanceofAndNullCheck.java
T
Tagir Valeevandintellij-monorepo-bot 3df6a002ba [java-dfa] Avoid joining nullable and flushed values
Improving IDEA-336371 False Negative NPE after instanceof check

GitOrigin-RevId: 512adf0cdee960d9e4c2ed623ea90f07e6a0927a
2023-10-30 21:48:22 +00:00

27 lines
542 B
Java

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
final class NullFP {
void test(@NotNull Y y) {}
interface X {
@Contract(pure = true)
@Nullable Y getY();
}
interface Y {}
interface Z extends Y {}
void run(@NotNull final X x) {
final Y y = x.getY();
if (y instanceof Z) {
unknown();
}
if (y == null) {}
test(<warning descr="Argument 'x.getY()' might be null">x.getY()</warning>);
}
native void unknown();
}