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
This commit is contained in:
Nikolay Krasko
2018-09-21 18:34:24 +03:00
parent b79dcbe8e6
commit dda1673096
@@ -203,20 +203,16 @@ object SourceNavigationHelper {
navigationKind: NavigationKind navigationKind: NavigationKind
): Collection<KtNamedDeclaration> { ): Collection<KtNamedDeclaration> {
val scopes = targetScopes(declaration, navigationKind) 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( val index: StringStubIndexExtension<out KtNamedDeclaration> = when (declaration) {
decompiledDeclaration: KtNamedDeclaration is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance()
): StringStubIndexExtension<out KtNamedDeclaration> = when (decompiledDeclaration) { is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance()
is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance() else -> throw IllegalArgumentException("Neither function nor declaration: " + declaration::class.java.name)
is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance() }
else -> throw IllegalArgumentException("Neither function nor declaration: " + decompiledDeclaration::class.java.name)
return scopes.flatMap { scope ->
index.get(declaration.fqName!!.asString(), declaration.project, scope)
}
} }
private fun getInitialMemberCandidates( private fun getInitialMemberCandidates(