Delete deprecated Type.Constructor message, advance ABI version
This commit is contained in:
@@ -101,19 +101,6 @@ message Annotation {
|
||||
}
|
||||
|
||||
message Type {
|
||||
message Constructor {
|
||||
enum Kind {
|
||||
CLASS = 0;
|
||||
TYPE_PARAMETER = 1;
|
||||
}
|
||||
|
||||
optional Kind kind = 1 [default = CLASS, (skip_in_comparison) = true];
|
||||
|
||||
required int32 id = 2 [(skip_in_comparison) = true]; // CLASS - fqName id, TYPE_PARAMETER - type parameter id
|
||||
}
|
||||
|
||||
required Constructor constructor = 1 [(skip_in_comparison) = true];
|
||||
|
||||
message Argument {
|
||||
enum Projection {
|
||||
IN = 0;
|
||||
@@ -142,10 +129,8 @@ message Type {
|
||||
|
||||
// Only one of the following values should be present. Consider using `oneof` instead when we upgrade to protobuf 2.6.0+
|
||||
|
||||
optional int32 constructor_class_name = 6 [(fq_name_id_in_table) = true]; // fqName id
|
||||
|
||||
optional int32 constructor_type_parameter = 7; // type parameter id
|
||||
|
||||
optional int32 class_name = 6 [(fq_name_id_in_table) = true]; // fqName id
|
||||
optional int32 type_parameter = 7; // type parameter id
|
||||
|
||||
extensions 100 to 199;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+2
-9
@@ -30,7 +30,7 @@ class DeserializedType(
|
||||
private val typeProto: ProtoBuf.Type,
|
||||
private val additionalAnnotations: Annotations = Annotations.EMPTY
|
||||
) : AbstractLazyType(c.storageManager), LazyType {
|
||||
private val typeDeserializer = c.typeDeserializer
|
||||
private val typeDeserializer: TypeDeserializer get() = c.typeDeserializer
|
||||
|
||||
override fun computeTypeConstructor() = typeDeserializer.typeConstructor(typeProto)
|
||||
|
||||
@@ -57,12 +57,5 @@ class DeserializedType(
|
||||
|
||||
override fun getCapabilities() = c.components.typeCapabilitiesLoader.loadCapabilities(typeProto)
|
||||
|
||||
fun getPresentableText(): String {
|
||||
val typeConstructorData = typeProto.getTypeConstructorData()
|
||||
val id = typeConstructorData.id
|
||||
return if (typeConstructorData.kind == TypeConstructorKind.CLASS)
|
||||
c.nameResolver.getClassId(id).asSingleFqName().asString()
|
||||
else
|
||||
"Unknown type parameter $id"
|
||||
}
|
||||
fun getPresentableText(): String = typeDeserializer.presentableTextForErrorType(typeProto)
|
||||
}
|
||||
|
||||
+17
-39
@@ -23,32 +23,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.LinkedHashMap
|
||||
|
||||
public enum class TypeConstructorKind {
|
||||
CLASS,
|
||||
TYPE_PARAMETER
|
||||
}
|
||||
|
||||
public data class TypeConstructorData(val kind: TypeConstructorKind, val id: Int)
|
||||
|
||||
public fun ProtoBuf.Type.getTypeConstructorData(): TypeConstructorData {
|
||||
if (hasConstructorClassName()) {
|
||||
assert(!hasConstructorTypeParameter(), "constructor_class_name already presents, so constructor_type_parameter should not be here")
|
||||
return TypeConstructorData(TypeConstructorKind.CLASS, constructorClassName)
|
||||
}
|
||||
else if (hasConstructorTypeParameter()) {
|
||||
assert(!hasConstructorClassName(), "constructor_type_parameter already presents, so constructor_class_name should not be here")
|
||||
return TypeConstructorData(TypeConstructorKind.TYPE_PARAMETER, constructorTypeParameter)
|
||||
}
|
||||
else {
|
||||
return when (constructor.kind) {
|
||||
ProtoBuf.Type.Constructor.Kind.CLASS -> TypeConstructorData(TypeConstructorKind.CLASS, constructor.id)
|
||||
ProtoBuf.Type.Constructor.Kind.TYPE_PARAMETER -> TypeConstructorData(TypeConstructorKind.TYPE_PARAMETER, constructor.id)
|
||||
else -> throw IllegalStateException("Unknown kind ${constructor.kind}")
|
||||
}
|
||||
}
|
||||
}
|
||||
import java.util.*
|
||||
|
||||
public class TypeDeserializer(
|
||||
private val c: DeserializationContext,
|
||||
@@ -95,20 +70,23 @@ public class TypeDeserializer(
|
||||
return DeserializedType(c, proto, additionalAnnotations)
|
||||
}
|
||||
|
||||
fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor {
|
||||
val typeConstructorData = proto.getTypeConstructorData()
|
||||
val id = typeConstructorData.id
|
||||
return typeConstructor(typeConstructorData) ?: ErrorUtils.createErrorType(
|
||||
if (typeConstructorData.kind == TypeConstructorKind.CLASS)
|
||||
c.nameResolver.getClassId(id).asSingleFqName().asString()
|
||||
else
|
||||
"Unknown type parameter $id"
|
||||
).constructor
|
||||
}
|
||||
fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor =
|
||||
when {
|
||||
proto.hasClassName() ->
|
||||
classDescriptors(proto.className)?.typeConstructor
|
||||
proto.hasTypeParameter() ->
|
||||
typeParameterTypeConstructor(proto.typeParameter)
|
||||
else ->
|
||||
null
|
||||
} ?: ErrorUtils.createErrorType(presentableTextForErrorType(proto)).constructor
|
||||
|
||||
private fun typeConstructor(data: TypeConstructorData): TypeConstructor? = when (data.kind) {
|
||||
TypeConstructorKind.CLASS -> classDescriptors(data.id)?.typeConstructor
|
||||
TypeConstructorKind.TYPE_PARAMETER -> typeParameterTypeConstructor(data.id)
|
||||
internal fun presentableTextForErrorType(proto: ProtoBuf.Type): String = when {
|
||||
proto.hasClassName() ->
|
||||
c.nameResolver.getClassId(proto.className).asSingleFqName().asString()
|
||||
proto.hasTypeParameter() ->
|
||||
"Unknown type parameter ${proto.typeParameter}"
|
||||
else ->
|
||||
"Unknown type"
|
||||
}
|
||||
|
||||
private fun typeParameterTypeConstructor(typeParameterId: Int): TypeConstructor? =
|
||||
|
||||
Reference in New Issue
Block a user