Minor, do not store FqName in LazyJavaClassDescriptor
This commit is contained in:
+8
-7
@@ -35,6 +35,8 @@ import org.jetbrains.kotlin.load.java.structure.JavaType
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.isValidJavaFqName
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NotFoundClasses
|
||||
@@ -44,14 +46,13 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.*
|
||||
|
||||
class LazyJavaClassDescriptor(
|
||||
private val outerC: LazyJavaResolverContext,
|
||||
private val outerContext: LazyJavaResolverContext,
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
internal val fqName: FqName,
|
||||
private val jClass: JavaClass
|
||||
) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName(),
|
||||
outerC.components.sourceElementFactory.source(jClass)), JavaClassDescriptor {
|
||||
) : ClassDescriptorBase(outerContext.storageManager, containingDeclaration, jClass.name,
|
||||
outerContext.components.sourceElementFactory.source(jClass)), JavaClassDescriptor {
|
||||
|
||||
private val c: LazyJavaResolverContext = outerC.child(this, jClass)
|
||||
private val c: LazyJavaResolverContext = outerContext.child(this, jClass)
|
||||
|
||||
init {
|
||||
c.components.javaResolverCache.recordClass(jClass, this)
|
||||
@@ -125,7 +126,7 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
override fun isCompanionObject() = false
|
||||
|
||||
override fun toString() = "lazy java class $fqName"
|
||||
override fun toString() = "Lazy Java class ${this.fqNameUnsafe}"
|
||||
|
||||
private inner class LazyJavaClassTypeConstructor : AbstractClassTypeConstructor(c.storageManager) {
|
||||
private val parameters = c.storageManager.createLazyValue {
|
||||
@@ -169,7 +170,7 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
private fun getPurelyImplementedSupertype(): KotlinType? {
|
||||
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName)
|
||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqNameSafe)
|
||||
?: return null
|
||||
|
||||
if (purelyImplementedFqName.isRoot || !purelyImplementedFqName.toUnsafe().startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return null
|
||||
|
||||
+7
-7
@@ -622,18 +622,18 @@ class LazyJavaClassMemberScope(
|
||||
if (jNestedClass == null) {
|
||||
val field = enumEntryIndex()[name]
|
||||
if (field != null) {
|
||||
val createLazyValue: NotNullLazyValue<Collection<Name>> = c.storageManager.createLazyValue {
|
||||
val enumMemberNames: NotNullLazyValue<Collection<Name>> = c.storageManager.createLazyValue {
|
||||
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })
|
||||
}
|
||||
EnumEntrySyntheticClassDescriptor.create(c.storageManager, ownerDescriptor, name,
|
||||
createLazyValue, c.resolveAnnotations(field), c.components.sourceElementFactory.source(field))
|
||||
EnumEntrySyntheticClassDescriptor.create(
|
||||
c.storageManager, ownerDescriptor, name, enumMemberNames, c.resolveAnnotations(field),
|
||||
c.components.sourceElementFactory.source(field)
|
||||
)
|
||||
}
|
||||
else null
|
||||
}
|
||||
else {
|
||||
LazyJavaClassDescriptor(
|
||||
c, ownerDescriptor, DescriptorUtils.getFqName(ownerDescriptor).child(name).toSafe(), jNestedClass
|
||||
)
|
||||
LazyJavaClassDescriptor(c, ownerDescriptor, jNestedClass)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,5 +659,5 @@ class LazyJavaClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString() = "Lazy java member scope for " + jClass.fqName
|
||||
override fun toString() = "Lazy Java member scope for " + jClass.fqName
|
||||
}
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class LazyJavaPackageScope(
|
||||
is KotlinClassLookupResult.NotFound -> {
|
||||
val javaClass = request.javaClass ?: c.components.finder.findClass(classId)
|
||||
javaClass?.let { it ->
|
||||
LazyJavaClassDescriptor(c, ownerDescriptor, it.fqName!!, it)
|
||||
LazyJavaClassDescriptor(c, ownerDescriptor, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user