K2 UAST: lookup declarations mangled due to value class
^KT-65653 fixed
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
Resolved to:
|
Resolved to:
|
||||||
PsiMethod:getColor(): PsiType:Color
|
PsiMethod:getColor-ywy1UOY(): PsiType:int
|
||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
Resolved to:
|
Resolved to:
|
||||||
PsiMethod:ColorProvider(resId: PsiType:int): PsiType:ColorProvider
|
PsiMethod:ColorProvider-MpdQY78(color: PsiType:int): PsiType:ColorProvider
|
||||||
+16
-2
@@ -86,7 +86,11 @@ private class KotlinStaticPsiDeclarationFromBinaryModuleProvider(
|
|||||||
// E.g., getJVM_FIELD -> JVM_FIELD
|
// E.g., getJVM_FIELD -> JVM_FIELD
|
||||||
nameWithoutPrefix == id ||
|
nameWithoutPrefix == id ||
|
||||||
// E.g., getFooBar -> FooBar -> fooBar
|
// E.g., getFooBar -> FooBar -> fooBar
|
||||||
nameWithoutPrefix.decapitalizeSmart().endsWith(id)
|
nameWithoutPrefix.decapitalizeSmart().let { decapitalizedPrefix ->
|
||||||
|
decapitalizedPrefix.endsWith(id) ||
|
||||||
|
// value class mangling: getColor-hash
|
||||||
|
isValueClassMangled(decapitalizedPrefix, id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
@@ -102,12 +106,22 @@ private class KotlinStaticPsiDeclarationFromBinaryModuleProvider(
|
|||||||
val classes = callableId.classId?.let { classId ->
|
val classes = callableId.classId?.let { classId ->
|
||||||
getClassesByClassId(classId)
|
getClassesByClassId(classId)
|
||||||
} ?: getClassesInPackage(callableId.packageName)
|
} ?: getClassesInPackage(callableId.packageName)
|
||||||
|
val id = callableId.callableName.identifier
|
||||||
return classes.flatMap { psiClass ->
|
return classes.flatMap { psiClass ->
|
||||||
psiClass.methods.filter { psiMethod ->
|
psiClass.methods.filter { psiMethod ->
|
||||||
psiMethod.name == callableId.callableName.identifier
|
psiMethod.name == id ||
|
||||||
|
// value class mangling: functionName-hash
|
||||||
|
isValueClassMangled(psiMethod.name, id)
|
||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isValueClassMangled(name: String, prefix: String): Boolean {
|
||||||
|
// A memory optimization for `name.startsWith("$prefix-")`, see KT-63486
|
||||||
|
return name.length > prefix.length &&
|
||||||
|
name[prefix.length] == '-' &&
|
||||||
|
name.startsWith(prefix)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinStaticPsiDeclarationProviderFactory(
|
class KotlinStaticPsiDeclarationProviderFactory(
|
||||||
|
|||||||
Reference in New Issue
Block a user