diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 2b72096a5a14..916475d4b5ba 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -1069,6 +1069,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { if (name.equals(variable.getName()) && !canBeReused.test(variable)) { throw new CancelException(); } + super.visitVariable(variable); } }); } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.after.java new file mode 100644 index 000000000000..fd8b15b3105a --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.after.java @@ -0,0 +1,14 @@ +import java.util.*; + +public class NestedLambdaNameConflict { + public void test(Map m){ + for(Map.Entry e : m.entrySet()) { + System.out.println(e.getKey()); + Foo foo = entry -> entry.getKey().equals(e.getValue()); + } + } + + interface Foo { + boolean doSmth(Map.Entry e); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.java new file mode 100644 index 000000000000..aaddc8c23113 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/performance/key_set_with_entry_set/NestedLambdaNameConflict.java @@ -0,0 +1,14 @@ +import java.util.*; + +public class NestedLambdaNameConflict { + public void test(Map m){ + for(String k : m.keySet()) { + System.out.println(k); + Foo foo = entry -> entry.getKey().equals(m.get(k)); + } + } + + interface Foo { + boolean doSmth(Map.Entry e); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/KeySetIterationMayUseEntrySetFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/KeySetIterationMayUseEntrySetFixTest.java index 9ffd256aabf5..39bdef7868d9 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/KeySetIterationMayUseEntrySetFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/KeySetIterationMayUseEntrySetFixTest.java @@ -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()")); } } \ No newline at end of file