Minor, move JavaFlexibleTypeDeserializer.id to JvmProtoBufUtil

To be able to read platform types with metadata.jvm
This commit is contained in:
Alexander Udalov
2018-03-09 15:02:45 +01:00
parent 241673c6a1
commit 9d8d4b837b
3 changed files with 9 additions and 6 deletions
@@ -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)
}
}
}
@@ -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)