mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
JavaCodeStyleManagerImpl#hasConflictingVariableAfterwards: check variable children as well
It could be a declaration which initializer contains a lambda. In this case lambda parameter name wasn't checked Fixes IDEA-206763 Iteration over keySet quickfix does not take into consideration that the variable name "entry" is already used by a lambda value
This commit is contained in:
+1
@@ -1069,6 +1069,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
if (name.equals(variable.getName()) && !canBeReused.test(variable)) {
|
||||
throw new CancelException();
|
||||
}
|
||||
super.visitVariable(variable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.util.*;
|
||||
|
||||
public class NestedLambdaNameConflict {
|
||||
public void test(Map<String, String> m){
|
||||
for(Map.Entry<String, String> e : m.entrySet()) {
|
||||
System.out.println(e.getKey());
|
||||
Foo foo = entry -> entry.getKey().equals(e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
boolean doSmth(Map.Entry<String, String> e);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.util.*;
|
||||
|
||||
public class NestedLambdaNameConflict {
|
||||
public void test(Map<String, String> m){
|
||||
for(String k : m.<caret>keySet()) {
|
||||
System.out.println(k);
|
||||
Foo foo = entry -> entry.getKey().equals(m.get(k));
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
boolean doSmth(Map.Entry<String, String> e);
|
||||
}
|
||||
}
|
||||
+1
@@ -52,5 +52,6 @@ public class KeySetIterationMayUseEntrySetFixTest extends IGQuickFixesTestCase {
|
||||
public void testLambda() { doTest(CommonQuickFixBundle.message("fix.replace.with.x", "Map.forEach()")); }
|
||||
public void testLambdaNoVar() { doTest(CommonQuickFixBundle.message("fix.replace.with.x", "Map.forEach()")); }
|
||||
public void testWildcardType() { doTest(CommonQuickFixBundle.message("fix.replace.with.x", "values()")); }
|
||||
public void testNestedLambdaNameConflict() { doTest(CommonQuickFixBundle.message("fix.replace.with.x", "entrySet()")); }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user