From dda1673096ecb68dbea952beda6a4a12c3d2fb0d Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 21 Sep 2018 18:34:24 +0300 Subject: [PATCH] Don't choose navigation target only by index (KT-26004) There might be situation when platform code has a declaration with another signature and the same fqname, but navigating to common declaration is expected. #KT-26004 Fixed --- .../navigation/SourceNavigationHelper.kt | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt index 89f770dc299..ca49f77404e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt @@ -203,20 +203,16 @@ object SourceNavigationHelper { navigationKind: NavigationKind ): Collection { val scopes = targetScopes(declaration, navigationKind) - val index = getIndexForTopLevelPropertyOrFunction(declaration) - for (scope in scopes) { - val candidates = index.get(declaration.fqName!!.asString(), declaration.project, scope) - if (candidates.isNotEmpty()) return candidates - } - return emptyList() - } - private fun getIndexForTopLevelPropertyOrFunction( - decompiledDeclaration: KtNamedDeclaration - ): StringStubIndexExtension = when (decompiledDeclaration) { - is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance() - is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance() - else -> throw IllegalArgumentException("Neither function nor declaration: " + decompiledDeclaration::class.java.name) + val index: StringStubIndexExtension = when (declaration) { + is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance() + is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance() + else -> throw IllegalArgumentException("Neither function nor declaration: " + declaration::class.java.name) + } + + return scopes.flatMap { scope -> + index.get(declaration.fqName!!.asString(), declaration.project, scope) + } } private fun getInitialMemberCandidates(