Do not store ClassDescriptor in EnumValue
Only store the ClassId of the enum class and the Name of the entry, and resolve the needed descriptor in getType() instead, which now takes the module instance where that descriptor should be resolved
This commit is contained in:
+2
-3
@@ -78,9 +78,8 @@ class AnnotationSerializer(private val stringTable: StringTable) {
|
||||
|
||||
override fun visitEnumValue(value: EnumValue, data: Unit) {
|
||||
type = Type.ENUM
|
||||
val enumEntry = value.value
|
||||
classId = stringTable.getFqNameIndex(enumEntry.containingDeclaration as ClassDescriptor)
|
||||
enumValueId = stringTable.getStringIndex(enumEntry.name.asString())
|
||||
classId = stringTable.getClassIdIndex(value.enumClassId)
|
||||
enumValueId = stringTable.getStringIndex(value.enumEntryName.asString())
|
||||
}
|
||||
|
||||
override fun visitErrorValue(value: ErrorValue, data: Unit) {
|
||||
|
||||
+8
-8
@@ -644,19 +644,19 @@ class DescriptorSerializer private constructor(
|
||||
proto.message = stringTable.getStringIndex(message)
|
||||
}
|
||||
|
||||
val level = (args[RequireKotlinNames.LEVEL] as? EnumValue)?.value?.name?.asString()
|
||||
val level = (args[RequireKotlinNames.LEVEL] as? EnumValue)?.enumEntryName?.asString()
|
||||
when (level) {
|
||||
DeprecationLevel.ERROR.toString() -> { /* ERROR is the default level */ }
|
||||
DeprecationLevel.WARNING.toString() -> proto.level = ProtoBuf.VersionRequirement.Level.WARNING
|
||||
DeprecationLevel.HIDDEN.toString() -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN
|
||||
DeprecationLevel.ERROR.name -> { /* ERROR is the default level */ }
|
||||
DeprecationLevel.WARNING.name -> proto.level = ProtoBuf.VersionRequirement.Level.WARNING
|
||||
DeprecationLevel.HIDDEN.name -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN
|
||||
}
|
||||
|
||||
val versionKind = (args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.value?.name?.asString()
|
||||
val versionKind = (args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.enumEntryName?.asString()
|
||||
when (versionKind) {
|
||||
ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.toString() -> { /* LANGUAGE_VERSION is the default kind */ }
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.toString() ->
|
||||
ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.name -> { /* LANGUAGE_VERSION is the default kind */ }
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.name ->
|
||||
proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION
|
||||
ProtoBuf.VersionRequirement.VersionKind.API_VERSION.toString() ->
|
||||
ProtoBuf.VersionRequirement.VersionKind.API_VERSION.name ->
|
||||
proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.API_VERSION
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import java.io.OutputStream
|
||||
|
||||
interface StringTable {
|
||||
@@ -24,5 +25,7 @@ interface StringTable {
|
||||
|
||||
fun getFqNameIndex(descriptor: ClassifierDescriptorWithTypeParameters): Int
|
||||
|
||||
fun getClassIdIndex(classId: ClassId): Int
|
||||
|
||||
fun serializeTo(output: OutputStream)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ open class StringTableImpl : StringTable {
|
||||
return getClassIdIndex(classId)
|
||||
}
|
||||
|
||||
fun getClassIdIndex(classId: ClassId): Int {
|
||||
override fun getClassIdIndex(classId: ClassId): Int {
|
||||
val builder = QualifiedName.newBuilder()
|
||||
builder.kind = QualifiedName.Kind.CLASS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user