Avoid retaining protobuf package within DeserializedPackageFragmentImpl
It's only used for DeserializedPackageMemberScope that's being created
during initialization
At the same time, protobuf objects may be not very light-weight
(see 2e933a165a)
#KT-24513 Fixed
This commit is contained in:
+5
-1
@@ -30,16 +30,20 @@ abstract class DeserializedPackageFragmentImpl(
|
||||
fqName: FqName,
|
||||
storageManager: StorageManager,
|
||||
module: ModuleDescriptor,
|
||||
protected val proto: ProtoBuf.PackageFragment,
|
||||
proto: ProtoBuf.PackageFragment,
|
||||
private val containerSource: DeserializedContainerSource?
|
||||
) : DeserializedPackageFragment(fqName, storageManager, module) {
|
||||
protected val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
|
||||
|
||||
override val classDataFinder = ProtoBasedClassDataFinder(proto, nameResolver) { containerSource ?: SourceElement.NO_SOURCE }
|
||||
|
||||
// Temporary storage: until `initialize` is called
|
||||
private var _proto: ProtoBuf.PackageFragment? = proto
|
||||
private lateinit var _memberScope: MemberScope
|
||||
|
||||
override fun initialize(components: DeserializationComponents) {
|
||||
val proto = _proto ?: error("Repeated call to DeserializedPackageFragmentImpl::initialize")
|
||||
_proto = null
|
||||
_memberScope = DeserializedPackageMemberScope(
|
||||
this, proto.`package`, nameResolver, containerSource, components,
|
||||
classNames = {
|
||||
|
||||
+2
-3
@@ -40,11 +40,10 @@ class KotlinJavascriptPackageFragment(
|
||||
header: JsProtoBuf.Header,
|
||||
configuration: DeserializationConfiguration
|
||||
) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header, configuration)) {
|
||||
val fileMap: Map<Int, FileHolder> by storageManager.createLazyValue {
|
||||
this.proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
|
||||
val fileMap: Map<Int, FileHolder> =
|
||||
proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
|
||||
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var annotationDeserializer: AnnotationDeserializer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user