mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't report subclass references inside lambdas in StaticInitializerReferencesSubClassInspection
This commit is contained in:
+6
-1
@@ -68,7 +68,12 @@ public class StaticInitializerReferencesSubClassInspection extends BaseJavaBatch
|
||||
scope.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (element instanceof PsiClass || element instanceof PsiReferenceParameterList || element instanceof PsiTypeElement) return;
|
||||
if (element instanceof PsiClass ||
|
||||
element instanceof PsiReferenceParameterList ||
|
||||
element instanceof PsiTypeElement ||
|
||||
element instanceof PsiLambdaExpression) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiClass targetClass = extractClass(element);
|
||||
if (targetClass != null && targetClass.isInheritor(baseClass, true) && !hasSingleInitializationPlace(targetClass)) {
|
||||
|
||||
+1
@@ -7,6 +7,7 @@ class Super {
|
||||
static Super USED_PRIVATE = new <warning descr="Referencing subclass MyUsedSub from superclass Super initializer might lead to class loading deadlock">MyUsedSub</warning>();
|
||||
|
||||
static Object OK_INSIDE_ANONYMOUS = new Object() {{ Sub s = new Sub(); }};
|
||||
static Runnable OK_INSIDE_LAMBDA = () -> { Sub s = new Sub(); };
|
||||
static Object OK_UNRELATED = "abc";
|
||||
static Super OK_SAME = new Super();
|
||||
static Super OK_SAME_ANONYMOUS = new Super(){};
|
||||
|
||||
Reference in New Issue
Block a user