Fix light classes exception occurring on obfuscated Kotlin libraries

^KT-29454 Fixed
This commit is contained in:
Denis.Zharkov
2020-12-23 11:07:15 +03:00
parent 7b9f6c1560
commit 77d4a46a6b
@@ -276,11 +276,10 @@ open class IDEKotlinAsJavaSupport(private val project: Project) : KotlinAsJavaSu
val relativeFqName = getClassRelativeName(decompiledClassOrObject) ?: return null
val iterator = relativeFqName.pathSegments().iterator()
val base = iterator.next()
assert(rootLightClassForDecompiledFile.name == base.asString()) {
"Light class for file:\n" + decompiledClassOrObject.containingKtFile.virtualFile.canonicalPath +
"\nwas expected to have name: " + base.asString() +
"\n Actual: " + rootLightClassForDecompiledFile.name
}
// In case class files have been obfuscated (i.e., SomeClass belongs to a.class file), just ignore them
if (rootLightClassForDecompiledFile.name != base.asString()) return null
var current: KtLightClassForDecompiledDeclaration = rootLightClassForDecompiledFile
while (iterator.hasNext()) {
val name = iterator.next()
@@ -349,4 +348,4 @@ open class IDEKotlinAsJavaSupport(private val project: Project) : KotlinAsJavaSu
internal fun PsiElement.getModuleInfoPreferringJvmPlatform(): IdeaModuleInfo {
return getPlatformModuleInfo(JvmPlatforms.unspecifiedJvmPlatform) ?: getModuleInfo()
}
}