Fix check for local classes in approximating string table
Take local/anonymous classes and their inner classes into account. Simplify approximation: use first available super classifier instead of first super class. This approximation should only happen for private declarations that were not previously approximated by frontend. So basically the only requirement for the approximated types is to be denotable. Note that this only works if the types are not used later. JVM uses a different string table implementatin as it needs exact types of private members for reflection. ^KT-20996 Fixed
This commit is contained in:
+4
-12
@@ -13,19 +13,11 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
|
||||
open class ApproximatingStringTable : StringTableImpl() {
|
||||
class ApproximatingStringTable : StringTableImpl() {
|
||||
override fun getLocalClassIdReplacement(descriptor: ClassifierDescriptorWithTypeParameters): ClassId? {
|
||||
return if (descriptor.containingDeclaration is CallableMemberDescriptor) {
|
||||
val superClassifiers = descriptor.getAllSuperClassifiers()
|
||||
.mapNotNull { it as ClassifierDescriptorWithTypeParameters }
|
||||
.filter { it != descriptor }
|
||||
.toList()
|
||||
if (superClassifiers.size == 1) {
|
||||
superClassifiers[0].classId
|
||||
} else {
|
||||
val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) }
|
||||
superClass?.classId ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe())
|
||||
}
|
||||
return if (DescriptorUtils.isLocal(descriptor)) {
|
||||
descriptor.getAllSuperClassifiers().firstOrNull()?.classId
|
||||
?: ClassId.topLevel(StandardNames.FqNames.any.toSafe())
|
||||
} else {
|
||||
super.getLocalClassIdReplacement(descriptor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user