boolean () { if(cachedNeedsThis == null) { ElementNeedsThis memberNeedsThis = new ElementNeedsThis(myTargetClass, myAnonOrLocalClass); myAnonOrLocalClass.accept(memberNeedsThis); class HasExplicitThis extends JavaRecursiveElementWalkingVisitor { boolean hasExplicitThis; @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { } @Override public void visitThisExpression(@NotNull PsiThisExpression expression) { hasExplicitThis = true; } } final HasExplicitThis hasExplicitThis = new HasExplicitThis(); if (myAnonOrLocalClass instanceof PsiAnonymousClass anonymousClass) { PsiExpressionList argList = anonymousClass.getArgumentList(); if (argList != null) argList.accept(hasExplicitThis); } cachedNeedsThis = memberNeedsThis.usesMembers() || hasExplicitThis.hasExplicitThis; } return cachedNeedsThis.booleanValue(); }