diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt index 85986740888..893091b35ca 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt @@ -174,7 +174,7 @@ fun PsiMethod.forEachOverridingMethod( val ktMember = this.unwrapped as? KtNamedDeclaration ?: return true val ktClass = runReadAction { ktMember.containingClassOrObject as? KtClass } ?: return true return forEachKotlinOverride(ktClass, listOf(ktMember), scope) { _, overrider -> - val lightMethods = runReadAction { overrider.toPossiblyFakeLightMethods() } + val lightMethods = runReadAction { overrider.toPossiblyFakeLightMethods().distinctBy { it.unwrapped } } lightMethods.all { processor(it) } } } diff --git a/idea/testData/navigation/implementations/ImplementsInInlineClass.kt b/idea/testData/navigation/implementations/ImplementsInInlineClass.kt new file mode 100644 index 00000000000..e739f4b35c5 --- /dev/null +++ b/idea/testData/navigation/implementations/ImplementsInInlineClass.kt @@ -0,0 +1,9 @@ +interface I { + fun x() +} + +inline class Foo(val value: Int) : I { + override fun x() {} +} + +// REF: (in Foo).x() \ No newline at end of file diff --git a/idea/testData/navigation/implementations/OverridesInInlineClass.kt b/idea/testData/navigation/implementations/OverridesInInlineClass.kt new file mode 100644 index 00000000000..b462fbf0f37 --- /dev/null +++ b/idea/testData/navigation/implementations/OverridesInInlineClass.kt @@ -0,0 +1,9 @@ +interface I { + fun x() = 1 +} + +inline class Foo(val value: Int) : I { + override fun x() = 2 +} + +// REF: (in Foo).x() \ No newline at end of file diff --git a/idea/testData/navigation/implementations/multiModule/expectClassSuperclass/common/common.kt b/idea/testData/navigation/implementations/multiModule/expectClassSuperclass/common/common.kt index d010e3b6771..41da632dfd5 100644 --- a/idea/testData/navigation/implementations/multiModule/expectClassSuperclass/common/common.kt +++ b/idea/testData/navigation/implementations/multiModule/expectClassSuperclass/common/common.kt @@ -8,6 +8,7 @@ class ExpectedChildChild : ExpectedChild() class SimpleChild : SimpleParent() +// DISTINCT_REF // REF: [testModule_Common] (test).ExpectedChild // REF: [testModule_Common] (test).ExpectedChildChild // REF: [testModule_Common] (test).SimpleChild diff --git a/idea/testData/navigation/implementations/multiModule/expectClassSuperclassProperty/common/common.kt b/idea/testData/navigation/implementations/multiModule/expectClassSuperclassProperty/common/common.kt index dca562673a9..36ee569da80 100644 --- a/idea/testData/navigation/implementations/multiModule/expectClassSuperclassProperty/common/common.kt +++ b/idea/testData/navigation/implementations/multiModule/expectClassSuperclassProperty/common/common.kt @@ -16,6 +16,7 @@ class SimpleChild : SimpleParent() { override val bar: Int get() = 1 } +// DISTINCT_REF // REF: [testModule_Common] (in test.ExpectedChild).bar // REF: [testModule_Common] (in test.ExpectedChildChild).bar // REF: [testModule_Common] (in test.SimpleChild).bar diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoImplementationTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoImplementationTestGenerated.java index 04b558117d1..afabcf978bd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoImplementationTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoImplementationTestGenerated.java @@ -104,6 +104,11 @@ public class KotlinGotoImplementationTestGenerated extends AbstractKotlinGotoImp runTest("idea/testData/navigation/implementations/ImplementGenericWithPrimitives.kt"); } + @TestMetadata("ImplementsInInlineClass.kt") + public void testImplementsInInlineClass() throws Exception { + runTest("idea/testData/navigation/implementations/ImplementsInInlineClass.kt"); + } + @TestMetadata("ObjectImported.kt") public void testObjectImported() throws Exception { runTest("idea/testData/navigation/implementations/ObjectImported.kt"); @@ -114,6 +119,11 @@ public class KotlinGotoImplementationTestGenerated extends AbstractKotlinGotoImp runTest("idea/testData/navigation/implementations/OverridesInEnumEntries.kt"); } + @TestMetadata("OverridesInInlineClass.kt") + public void testOverridesInInlineClass() throws Exception { + runTest("idea/testData/navigation/implementations/OverridesInInlineClass.kt"); + } + @TestMetadata("PropertyOverriddenNavigation.kt") public void testPropertyOverriddenNavigation() throws Exception { runTest("idea/testData/navigation/implementations/PropertyOverriddenNavigation.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/NavigationTestUtils.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/NavigationTestUtils.java index 0277112e20b..c454c4e05c2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/NavigationTestUtils.java +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/NavigationTestUtils.java @@ -45,8 +45,9 @@ public final class NavigationTestUtils { } public static void assertGotoDataMatching(Editor editor, GotoTargetHandler.GotoData gotoData, boolean renderModule) { + String documentText = editor.getDocument().getText(); // Get expected references from the tested document - List expectedReferences = InTextDirectivesUtils.findListWithPrefixes(editor.getDocument().getText(), "// REF:"); + List expectedReferences = InTextDirectivesUtils.findListWithPrefixes(documentText, "// REF:"); for (int i = 0; i < expectedReferences.size(); i++) { String expectedText = expectedReferences.get(i); expectedText = expectedText.replace("\\n", "\n"); @@ -59,9 +60,14 @@ public final class NavigationTestUtils { Collections.sort(expectedReferences); if (gotoData != null) { - List distinctTargets = ArraysKt.distinctBy(gotoData.targets, element -> LightClassUtilsKt.getUnwrapped(element)); + List targets; + if (InTextDirectivesUtils.isDirectiveDefined(documentText, "// DISTINCT_REF")) { + targets = ArraysKt.distinctBy(gotoData.targets, element -> LightClassUtilsKt.getUnwrapped(element)); + } else { + targets = Arrays.asList(gotoData.targets); + } // Transform given reference result to strings - List psiElements = Lists.transform(distinctTargets, new Function() { + List psiElements = Lists.transform(targets, new Function() { @Override public String apply(@Nullable PsiElement element) { Assert.assertNotNull(element);