mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
anonym -> lambda: forbid when result in illegal self reference (IDEA-126763)
This commit is contained in:
@@ -433,6 +433,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) {
|
||||
final PsiExpression initializer = ((PsiField)resolved).getInitializer();
|
||||
if (initializer == null ||
|
||||
resolved == field ||
|
||||
initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with lambda" "false"
|
||||
class Test {
|
||||
Runnable runnable = new Runn<caret>able() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(runnable);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user