mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
copy to final: ensure to walk up through nested lambdas (IDEA-177496)
This commit is contained in:
+1
-1
@@ -238,7 +238,7 @@ public class VariableAccessFromInnerClassFix implements IntentionAction {
|
||||
}
|
||||
PsiElement element = statement;
|
||||
while (element != declarationScope && !(element instanceof PsiFile)) {
|
||||
if (element instanceof PsiClass) {
|
||||
if (element instanceof PsiClass || element instanceof PsiLambdaExpression) {
|
||||
statement = statement.getParent();
|
||||
continue nextInnerClass;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Copy 'a' to effectively final temp variable" "true"
|
||||
class Test {
|
||||
public void test() {
|
||||
int a = 1;
|
||||
a = 2;
|
||||
int finalA = a;
|
||||
Runnable r = () -> {
|
||||
Runnable rr = () -> System.out.println(finalA);
|
||||
};
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Copy 'a' to effectively final temp variable" "true"
|
||||
class Test {
|
||||
public void test() {
|
||||
int a = 1;
|
||||
a = 2;
|
||||
Runnable r = () -> {
|
||||
Runnable rr = () -> System.out.println(<caret>a);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user