mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-130111 "Constant conditions & exceptions" inspection: false positive for possible NPE
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class FooWithComments {
|
||||
void unimportantMethod() {
|
||||
AnEnum ae = nullableGetter();
|
||||
if (ae != null) {
|
||||
if (ae == AnEnum.ENUM_VALUE) {
|
||||
anotherMethod(ae.name()); // IDEA warns that ae.name() could cause NPE
|
||||
} else {
|
||||
// do something else
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private native void anotherMethod(String name);
|
||||
|
||||
@Nullable
|
||||
private native AnEnum nullableGetter();
|
||||
|
||||
enum AnEnum {
|
||||
ENUM_VALUE, FOO2
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testVisitFinallyOnce() throws Throwable { doTest(); }
|
||||
public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); }
|
||||
public void testEqualsEnumConstant() throws Throwable { doTest(); }
|
||||
public void testEnumConstantNotNull() throws Throwable { doTest(); }
|
||||
public void testEqualsConstant() throws Throwable { doTest(); }
|
||||
public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); }
|
||||
public void testGreaterIsNotEquals() throws Throwable { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user