[KLIB] Support error code in metadata
This commit is contained in:
+3
-2
@@ -23,8 +23,9 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
class KlibMetadataIncrementalSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
skipExpects: Boolean
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects) {
|
||||
skipExpects: Boolean,
|
||||
allowErrorTypes: Boolean = false
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects, allowErrorTypes = allowErrorTypes) {
|
||||
|
||||
fun serializePackageFragment(
|
||||
module: ModuleDescriptor,
|
||||
|
||||
+3
-2
@@ -23,8 +23,9 @@ class KlibMetadataMonolithicSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
skipExpects: Boolean,
|
||||
includeOnlyModuleContent: Boolean = false
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects, includeOnlyModuleContent) {
|
||||
includeOnlyModuleContent: Boolean = false,
|
||||
allowErrorTypes: Boolean = false
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, skipExpects, includeOnlyModuleContent, allowErrorTypes) {
|
||||
|
||||
private fun serializePackageFragment(fqName: FqName, module: ModuleDescriptor): List<ProtoBuf.PackageFragment> {
|
||||
|
||||
|
||||
+4
-2
@@ -32,7 +32,8 @@ abstract class KlibMetadataSerializer(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val metadataVersion: BinaryVersion,
|
||||
val skipExpects: Boolean = false,
|
||||
val includeOnlyModuleContent: Boolean = false
|
||||
val includeOnlyModuleContent: Boolean = false,
|
||||
private val allowErrorTypes: Boolean
|
||||
) {
|
||||
|
||||
lateinit var serializerContext: SerializerContext
|
||||
@@ -48,7 +49,8 @@ abstract class KlibMetadataSerializer(
|
||||
val extension = KlibMetadataSerializerExtension(
|
||||
languageVersionSettings,
|
||||
metadataVersion,
|
||||
KlibMetadataStringTable()
|
||||
KlibMetadataStringTable(),
|
||||
allowErrorTypes
|
||||
)
|
||||
return SerializerContext(
|
||||
extension,
|
||||
|
||||
+7
-1
@@ -17,11 +17,13 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl
|
||||
import org.jetbrains.kotlin.types.FlexibleType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class KlibMetadataSerializerExtension(
|
||||
private val languageVersionSettings: LanguageVersionSettings,
|
||||
override val metadataVersion: BinaryVersion,
|
||||
override val stringTable: StringTableImpl
|
||||
override val stringTable: StringTableImpl,
|
||||
private val allowErrorTypes: Boolean
|
||||
) : KotlinSerializerExtensionBase(KlibMetadataSerializerProtocol) {
|
||||
override fun shouldUseTypeTable(): Boolean = true
|
||||
|
||||
@@ -34,6 +36,10 @@ class KlibMetadataSerializerExtension(
|
||||
lowerProto.flexibleTypeCapabilitiesId = stringTable.getStringIndex(DynamicTypeDeserializer.id)
|
||||
}
|
||||
|
||||
override fun serializeErrorType(type: KotlinType, builder: ProtoBuf.Type.Builder) {
|
||||
if (!allowErrorTypes) super.serializeErrorType(type, builder)
|
||||
}
|
||||
|
||||
override fun serializeClass(
|
||||
descriptor: ClassDescriptor,
|
||||
proto: ProtoBuf.Class.Builder,
|
||||
|
||||
Reference in New Issue
Block a user