diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringUtil.java b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringUtil.java index a7fccf5dcec..0878275e1d8 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringUtil.java +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringUtil.java @@ -122,9 +122,11 @@ public class JetRefactoringUtil { "fun checkSuperMethods(declaration: JetDeclaration, ignore: Collection?, actionStringKey: String): MutableList?") @Nullable public static List checkSuperMethods( - @NotNull JetDeclaration declaration, @Nullable Collection ignore, @NotNull String actionStringKey + @NotNull JetDeclaration declaration, + @Nullable Collection ignore, + @NotNull String actionStringKey ) { - final BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(declaration); + BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(declaration); CallableDescriptor declarationDescriptor = (CallableDescriptor)bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration); @@ -133,20 +135,14 @@ public class JetRefactoringUtil { return Collections.singletonList(declaration); } - final Project project = declaration.getProject(); - Map overriddenElementsToDescriptor = ContainerUtil.map2Map( - OverrideResolver.getAllOverriddenDescriptors(declarationDescriptor), - new Function>() { - @Override - public Pair fun(CallableDescriptor descriptor) { - return new Pair( - DescriptorToDeclarationUtil.getDeclaration(project, descriptor), - descriptor - ); - } - } - ); - overriddenElementsToDescriptor.remove(null); + Project project = declaration.getProject(); + Map overriddenElementsToDescriptor = new HashMap(); + for (CallableDescriptor overridenDescriptor : OverrideResolver.getAllOverriddenDescriptors(declarationDescriptor)) { + PsiElement overridenDeclaration = DescriptorToDeclarationUtil.getDeclaration(project, overridenDescriptor); + if (overridenDeclaration != null) { + overriddenElementsToDescriptor.put(overridenDeclaration, overridenDescriptor); + } + } if (ignore != null) { overriddenElementsToDescriptor.keySet().removeAll(ignore); } diff --git a/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt b/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt new file mode 100644 index 00000000000..7ecfb31e70a --- /dev/null +++ b/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt @@ -0,0 +1,13 @@ +// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetNamedFunction +// OPTIONS: usages, skipImports + +open data class A(val a: Int) + +class B(b: Int): A(b) { + override fun copy(b: Int): B = B(b) +} + +fun main(a: A) { + a.copy(1) + B(0).copy(1) +} \ No newline at end of file diff --git a/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.results.txt b/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.results.txt new file mode 100644 index 00000000000..81e9b32735d --- /dev/null +++ b/idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.results.txt @@ -0,0 +1 @@ +Function call (12: 10) B(0).copy(1) diff --git a/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java b/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java index ff8af5fabef..3cc5d34d69e 100644 --- a/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java @@ -418,6 +418,11 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest { doTest("idea/testData/findUsages/kotlin/findFunctionUsages/kotlinTopLevelMethodUsagesNoImport.0.kt"); } + @TestMetadata("synthesizedFunction.0.kt") + public void testSynthesizedFunction() throws Exception { + doTest("idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt"); + } + @TestMetadata("usagesOfBaseForFunction.0.kt") public void testUsagesOfBaseForFunction() throws Exception { doTest("idea/testData/findUsages/kotlin/findFunctionUsages/usagesOfBaseForFunction.0.kt");