Rework DescriptorSerializerPlugin to be a part of Project's extensions
instead of statically registering it. Static registering can cause subtle errors when plugin implementation (e.g. SerializationDescriptorPluginForKotlinxSerialization) is registered from multiple classloaders: in multi-module with daemon compilation scenario #KT-41857 Fixed
This commit is contained in:
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
@@ -22,9 +23,10 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
class KlibMetadataIncrementalSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
project: Project,
|
||||
skipExpects: Boolean,
|
||||
allowErrorTypes: Boolean = false
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects, allowErrorTypes = allowErrorTypes) {
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, project, skipExpects, allowErrorTypes = allowErrorTypes) {
|
||||
|
||||
fun serializePackageFragment(
|
||||
module: ModuleDescriptor,
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.packageFragments
|
||||
@@ -22,10 +23,11 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
class KlibMetadataMonolithicSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
project: Project?,
|
||||
skipExpects: Boolean,
|
||||
includeOnlyModuleContent: Boolean = false,
|
||||
allowErrorTypes: Boolean = false
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects, includeOnlyModuleContent, allowErrorTypes) {
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, project, skipExpects, includeOnlyModuleContent, allowErrorTypes) {
|
||||
|
||||
private fun serializePackageFragment(fqName: FqName, module: ModuleDescriptor): List<ProtoBuf.PackageFragment> {
|
||||
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isExpectMember
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isSerializableExpectClass
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
@@ -31,6 +32,7 @@ internal fun <T, R> Iterable<T>.maybeChunked(size: Int?, transform: (List<T>) ->
|
||||
abstract class KlibMetadataSerializer(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val metadataVersion: BinaryVersion,
|
||||
val project: Project?,
|
||||
val skipExpects: Boolean = false,
|
||||
val includeOnlyModuleContent: Boolean = false,
|
||||
private val allowErrorTypes: Boolean
|
||||
@@ -93,7 +95,7 @@ abstract class KlibMetadataSerializer(
|
||||
with(serializerContext) {
|
||||
val previousSerializer = classSerializer
|
||||
|
||||
classSerializer = DescriptorSerializer.create(classDescriptor, serializerExtension, classSerializer)
|
||||
classSerializer = DescriptorSerializer.create(classDescriptor, serializerExtension, classSerializer, project)
|
||||
val classProto = classSerializer.classProto(classDescriptor).build() ?: error("Class not serialized: $classDescriptor")
|
||||
//builder.addClass(classProto)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user