IDEA-152933 (Return of instance of anonymous, local or inner class shall ignore static methods)

This commit is contained in:
Bas Leijdekkers
2016-03-14 16:09:12 +01:00
parent 00be750ad0
commit 451365caaa
2 changed files with 6 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ public class ReturnOfInnerClassInspection extends BaseInspection {
return;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(statement, PsiMethod.class, true, PsiLambdaExpression.class);
if (method == null || method.hasModifierProperty(PsiModifier.PRIVATE)) {
if (method == null || method.hasModifierProperty(PsiModifier.PRIVATE) || method.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
else if (ignoreNonPublic &&
@@ -1,5 +1,9 @@
public class ReturnOfInnerClass {
public static Object zero() {
return new Object() {};
}
public Object one() {
<warning descr="Return of instance of anonymous class">return</warning> new Object() {};
}