IDEA-221312 NPE warning on instance-qualified static method call

GitOrigin-RevId: cb7844ba9cb97413161402fb0ff187d0a5ee7922
This commit is contained in:
Tagir Valeev
2019-09-10 04:43:14 +00:00
committed by intellij-monorepo-bot
parent e4d94d10a7
commit 964884225d
3 changed files with 15 additions and 0 deletions
@@ -160,6 +160,10 @@ public class NullabilityProblemKind<T extends PsiElement> {
}
PsiElement parent = context.getParent();
if (parent instanceof PsiReferenceExpression) {
PsiElement resolved = ((PsiReferenceExpression)parent).resolve();
if (resolved instanceof PsiMember && ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC)) {
return null;
}
PsiElement grandParent = parent.getParent();
if (grandParent instanceof PsiMethodCallExpression) {
return callNPE.problem((PsiMethodCallExpression)grandParent, expression);
@@ -0,0 +1,10 @@
class Null {
public static void greet() {
System.out.println("Hello World");
}
public static void main(String[] args) {
Null null1 = null;
null1.greet();
}
}
@@ -666,4 +666,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
public void testArrayElementLocality() { doTest(); }
public void testOverwrittenParameter() { doTest(); }
public void testClassCastExceptionDispatch() { doTest(); }
public void testInstanceQualifiedStaticMember() { doTest(); }
}