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.FqName
|
||||||
import org.jetbrains.kotlin.name.isValidJavaFqName
|
import org.jetbrains.kotlin.name.isValidJavaFqName
|
||||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
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.InnerClassesScopeWrapper
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.NotFoundClasses
|
import org.jetbrains.kotlin.serialization.deserialization.NotFoundClasses
|
||||||
@@ -44,14 +46,13 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class LazyJavaClassDescriptor(
|
class LazyJavaClassDescriptor(
|
||||||
private val outerC: LazyJavaResolverContext,
|
private val outerContext: LazyJavaResolverContext,
|
||||||
containingDeclaration: DeclarationDescriptor,
|
containingDeclaration: DeclarationDescriptor,
|
||||||
internal val fqName: FqName,
|
|
||||||
private val jClass: JavaClass
|
private val jClass: JavaClass
|
||||||
) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName(),
|
) : ClassDescriptorBase(outerContext.storageManager, containingDeclaration, jClass.name,
|
||||||
outerC.components.sourceElementFactory.source(jClass)), JavaClassDescriptor {
|
outerContext.components.sourceElementFactory.source(jClass)), JavaClassDescriptor {
|
||||||
|
|
||||||
private val c: LazyJavaResolverContext = outerC.child(this, jClass)
|
private val c: LazyJavaResolverContext = outerContext.child(this, jClass)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
c.components.javaResolverCache.recordClass(jClass, this)
|
c.components.javaResolverCache.recordClass(jClass, this)
|
||||||
@@ -125,7 +126,7 @@ class LazyJavaClassDescriptor(
|
|||||||
|
|
||||||
override fun isCompanionObject() = false
|
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 inner class LazyJavaClassTypeConstructor : AbstractClassTypeConstructor(c.storageManager) {
|
||||||
private val parameters = c.storageManager.createLazyValue {
|
private val parameters = c.storageManager.createLazyValue {
|
||||||
@@ -169,7 +170,7 @@ class LazyJavaClassDescriptor(
|
|||||||
|
|
||||||
private fun getPurelyImplementedSupertype(): KotlinType? {
|
private fun getPurelyImplementedSupertype(): KotlinType? {
|
||||||
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
||||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName)
|
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqNameSafe)
|
||||||
?: return null
|
?: return null
|
||||||
|
|
||||||
if (purelyImplementedFqName.isRoot || !purelyImplementedFqName.toUnsafe().startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) 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) {
|
if (jNestedClass == null) {
|
||||||
val field = enumEntryIndex()[name]
|
val field = enumEntryIndex()[name]
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
val createLazyValue: NotNullLazyValue<Collection<Name>> = c.storageManager.createLazyValue {
|
val enumMemberNames: NotNullLazyValue<Collection<Name>> = c.storageManager.createLazyValue {
|
||||||
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })
|
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })
|
||||||
}
|
}
|
||||||
EnumEntrySyntheticClassDescriptor.create(c.storageManager, ownerDescriptor, name,
|
EnumEntrySyntheticClassDescriptor.create(
|
||||||
createLazyValue, c.resolveAnnotations(field), c.components.sourceElementFactory.source(field))
|
c.storageManager, ownerDescriptor, name, enumMemberNames, c.resolveAnnotations(field),
|
||||||
|
c.components.sourceElementFactory.source(field)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LazyJavaClassDescriptor(
|
LazyJavaClassDescriptor(c, ownerDescriptor, jNestedClass)
|
||||||
c, ownerDescriptor, DescriptorUtils.getFqName(ownerDescriptor).child(name).toSafe(), 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 -> {
|
is KotlinClassLookupResult.NotFound -> {
|
||||||
val javaClass = request.javaClass ?: c.components.finder.findClass(classId)
|
val javaClass = request.javaClass ?: c.components.finder.findClass(classId)
|
||||||
javaClass?.let { it ->
|
javaClass?.let { it ->
|
||||||
LazyJavaClassDescriptor(c, ownerDescriptor, it.fqName!!, it)
|
LazyJavaClassDescriptor(c, ownerDescriptor, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user