Refactoring. Removed all usages of asSimpleType except related to TypeSubstitution.
This commit is contained in:
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets
|
||||
import org.jetbrains.kotlin.types.AbstractLazyType
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.withAbbreviatedType
|
||||
import org.jetbrains.kotlin.types.withAbbreviation
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
|
||||
class DeserializedType private constructor(
|
||||
@@ -58,7 +58,7 @@ class DeserializedType private constructor(
|
||||
val deserializedType = DeserializedType(c, typeProto, additionalAnnotations)
|
||||
val abbreviatedTypeProto = typeProto.abbreviatedType(c.typeTable) ?: return deserializedType
|
||||
|
||||
return deserializedType.withAbbreviatedType(DeserializedType(c, abbreviatedTypeProto, additionalAnnotations))
|
||||
return deserializedType.withAbbreviation(DeserializedType(c, abbreviatedTypeProto, additionalAnnotations))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -180,8 +180,8 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val local = c.childContext(typeAlias, proto.typeParameterList)
|
||||
typeAlias.initialize(
|
||||
local.typeDeserializer.ownTypeParameters,
|
||||
local.typeDeserializer.type(proto.underlyingType(c.typeTable)),
|
||||
local.typeDeserializer.type(proto.expandedType(c.typeTable))
|
||||
local.typeDeserializer.simpleType(proto.underlyingType(c.typeTable)),
|
||||
local.typeDeserializer.simpleType(proto.expandedType(c.typeTable))
|
||||
)
|
||||
|
||||
return typeAlias
|
||||
|
||||
+6
-3
@@ -58,14 +58,17 @@ class TypeDeserializer(
|
||||
fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KotlinType {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId)
|
||||
val lowerBound = DeserializedType.create(c, proto, additionalAnnotations)
|
||||
val upperBound = DeserializedType.create(c, proto.flexibleUpperBound(c.typeTable)!!, additionalAnnotations)
|
||||
val lowerBound = simpleType(proto, additionalAnnotations)
|
||||
val upperBound = simpleType(proto.flexibleUpperBound(c.typeTable)!!, additionalAnnotations)
|
||||
return c.components.flexibleTypeDeserializer.create(proto, id, lowerBound, upperBound)
|
||||
}
|
||||
|
||||
return DeserializedType.create(c, proto, additionalAnnotations)
|
||||
return simpleType(proto, additionalAnnotations)
|
||||
}
|
||||
|
||||
fun simpleType(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY)
|
||||
= DeserializedType.create(c, proto, additionalAnnotations)
|
||||
|
||||
fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor =
|
||||
when {
|
||||
proto.hasClassName() -> {
|
||||
|
||||
+7
-9
@@ -24,9 +24,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
interface DeserializedMemberDescriptor : MemberDescriptor {
|
||||
val proto: MessageLite
|
||||
@@ -154,14 +152,14 @@ class DeserializedTypeAliasDescriptor(
|
||||
) : AbstractTypeAliasDescriptor(containingDeclaration, annotations, name, SourceElement.NO_SOURCE, visibility),
|
||||
DeserializedMemberDescriptor {
|
||||
|
||||
override lateinit var underlyingType: KotlinType private set
|
||||
override lateinit var expandedType: KotlinType private set
|
||||
override lateinit var underlyingType: SimpleType private set
|
||||
override lateinit var expandedType: SimpleType private set
|
||||
private lateinit var typeConstructorParameters: List<TypeParameterDescriptor>
|
||||
|
||||
fun initialize(
|
||||
declaredTypeParameters: List<TypeParameterDescriptor>,
|
||||
underlyingType: KotlinType,
|
||||
expandedType: KotlinType
|
||||
underlyingType: SimpleType,
|
||||
expandedType: SimpleType
|
||||
) {
|
||||
initialize(declaredTypeParameters)
|
||||
this.underlyingType = underlyingType
|
||||
@@ -173,8 +171,8 @@ class DeserializedTypeAliasDescriptor(
|
||||
if (substitutor.isEmpty) return this
|
||||
val substituted = DeserializedTypeAliasDescriptor(containingDeclaration, annotations, name, visibility, proto, nameResolver, typeTable, containerSource)
|
||||
substituted.initialize(declaredTypeParameters,
|
||||
substitutor.safeSubstitute(underlyingType, Variance.INVARIANT),
|
||||
substitutor.safeSubstitute(expandedType, Variance.INVARIANT))
|
||||
substitutor.safeSubstitute(underlyingType, Variance.INVARIANT).asSimpleType(),
|
||||
substitutor.safeSubstitute(expandedType, Variance.INVARIANT).asSimpleType())
|
||||
|
||||
return substituted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user