[FIR] Don't keep ref to whole class proto
Store module name only
This commit is contained in:
committed by
teamcityserver
parent
a121061df7
commit
617d99faac
+3
-1
@@ -215,7 +215,9 @@ fun deserializeClassToSymbol(
|
||||
|
||||
it.sourceElement = containerSource
|
||||
|
||||
it.proto = FirClassProto(classProto, nameResolver)
|
||||
classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)?.let { idx ->
|
||||
it.moduleName = nameResolver.getString(idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.isFakeOverride
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class Fir2IrLazyClass(
|
||||
@@ -204,11 +202,8 @@ class Fir2IrLazyClass(
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
override val classProto: ProtoBuf.Class?
|
||||
get() = fir.proto?.classProto
|
||||
|
||||
override val nameResolver: NameResolver?
|
||||
get() = fir.proto?.nameResolver
|
||||
override val moduleName: String?
|
||||
get() = fir.moduleName
|
||||
|
||||
private fun FirNamedFunctionSymbol.isAbstractMethodOfAny(): Boolean {
|
||||
val fir = fir
|
||||
|
||||
@@ -184,11 +184,9 @@ private object SourceElementKey : FirDeclarationDataKey()
|
||||
|
||||
var FirRegularClass.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
||||
|
||||
private object ClassProtoKey : FirDeclarationDataKey()
|
||||
private object ModuleNameKey : FirDeclarationDataKey()
|
||||
|
||||
class FirClassProto(val classProto: ProtoBuf.Class, val nameResolver: NameResolver)
|
||||
|
||||
var FirRegularClass.proto: FirClassProto? by FirDeclarationDataRegistry.data(ClassProtoKey)
|
||||
var FirRegularClass.moduleName: String? by FirDeclarationDataRegistry.data(ModuleNameKey)
|
||||
|
||||
var FirTypeAlias.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
||||
|
||||
|
||||
+3
-1
@@ -499,13 +499,15 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
||||
var current: IrDeclarationParent? = function.parent
|
||||
while (current != null) {
|
||||
when (current) {
|
||||
is IrMaybeDeserializedClass -> {
|
||||
is IrLazyClass -> {
|
||||
val classProto = current.classProto ?: return null
|
||||
val nameResolver = current.nameResolver ?: return null
|
||||
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
|
||||
?.let(nameResolver::getString)
|
||||
?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
||||
}
|
||||
is IrMaybeDeserializedClass ->
|
||||
return current.moduleName
|
||||
is IrExternalPackageFragment -> {
|
||||
val source = current.containerSource ?: return null
|
||||
return (source as? JvmPackagePartSource)?.moduleName
|
||||
|
||||
@@ -40,7 +40,7 @@ class IrLazyClass(
|
||||
override val isFun: Boolean,
|
||||
override val stubGenerator: DeclarationStubGenerator,
|
||||
override val typeTranslator: TypeTranslator
|
||||
) : IrClass(), IrLazyDeclarationBase, IrMaybeDeserializedClass {
|
||||
) : IrClass(), IrLazyDeclarationBase {
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
@@ -103,8 +103,8 @@ class IrLazyClass(
|
||||
|
||||
override var attributeOwnerId: IrAttributeContainer = this
|
||||
|
||||
override val classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
|
||||
override val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
||||
val classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
|
||||
val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
||||
override val source: SourceElement get() = descriptor.source
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
|
||||
+1
-4
@@ -6,10 +6,7 @@
|
||||
package org.jetbrains.kotlin.ir.declarations.lazy
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
|
||||
interface IrMaybeDeserializedClass : IrDeclaration {
|
||||
val classProto: ProtoBuf.Class?
|
||||
val nameResolver: NameResolver?
|
||||
val moduleName: String?
|
||||
}
|
||||
Reference in New Issue
Block a user