IDEA-130111 "Constant conditions & exceptions" inspection: false positive for possible NPE

This commit is contained in:
peter
2014-09-22 12:44:45 +02:00
parent db95c2203d
commit 12553cb3de
3 changed files with 31 additions and 10 deletions
@@ -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(); }