Minor, move JavaFlexibleTypeDeserializer.id to JvmProtoBufUtil
To be able to read platform types with metadata.jvm
This commit is contained in:
+2
-2
@@ -29,11 +29,11 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawTypeImpl;
|
||||
import org.jetbrains.kotlin.load.kotlin.JavaFlexibleTypeDeserializer;
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt;
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf;
|
||||
import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf;
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.ClassMapperLite;
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.protobuf.GeneratedMessageLite;
|
||||
@@ -132,7 +132,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
@NotNull ProtoBuf.Type.Builder lowerProto,
|
||||
@NotNull ProtoBuf.Type.Builder upperProto
|
||||
) {
|
||||
lowerProto.setFlexibleTypeCapabilitiesId(getStringTable().getStringIndex(JavaFlexibleTypeDeserializer.INSTANCE.getId()));
|
||||
lowerProto.setFlexibleTypeCapabilitiesId(getStringTable().getStringIndex(JvmProtoBufUtil.PLATFORM_TYPE_ID));
|
||||
|
||||
if (flexibleType instanceof RawTypeImpl) {
|
||||
lowerProto.setExtension(JvmProtoBuf.isRaw, true);
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawTypeImpl
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeDeserializer
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -26,13 +27,13 @@ import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
|
||||
object JavaFlexibleTypeDeserializer : FlexibleTypeDeserializer {
|
||||
val id = "kotlin.jvm.PlatformType"
|
||||
|
||||
override fun create(proto: ProtoBuf.Type, flexibleId: String, lowerBound: SimpleType, upperBound: SimpleType): KotlinType {
|
||||
if (flexibleId != id) return ErrorUtils.createErrorType("Error java flexible type with id: $flexibleId. ($lowerBound..$upperBound)")
|
||||
if (flexibleId != JvmProtoBufUtil.PLATFORM_TYPE_ID) {
|
||||
return ErrorUtils.createErrorType("Error java flexible type with id: $flexibleId. ($lowerBound..$upperBound)")
|
||||
}
|
||||
if (proto.hasExtension(JvmProtoBuf.isRaw)) {
|
||||
return RawTypeImpl(lowerBound, upperBound)
|
||||
}
|
||||
return KotlinTypeFactory.flexibleType(lowerBound, upperBound)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -15,6 +15,8 @@ import java.io.InputStream
|
||||
object JvmProtoBufUtil {
|
||||
val EXTENSION_REGISTRY: ExtensionRegistryLite = ExtensionRegistryLite.newInstance().apply(JvmProtoBuf::registerAllExtensions)
|
||||
|
||||
const val PLATFORM_TYPE_ID = "kotlin.jvm.PlatformType"
|
||||
|
||||
@JvmStatic
|
||||
fun readClassDataFrom(data: Array<String>, strings: Array<String>): Pair<JvmNameResolver, ProtoBuf.Class> =
|
||||
readClassDataFrom(BitEncoding.decodeBytes(data), strings)
|
||||
|
||||
Reference in New Issue
Block a user