[FIR] Properly deserialize type attributes for type arguments
#KT-41991 Fixed
This commit is contained in:
+1
-1
@@ -152,7 +152,7 @@ class FirContractDeserializer(private val c: FirDeserializationContext) {
|
||||
}
|
||||
|
||||
private fun extractType(proto: ProtoBuf.Expression): ConeKotlinType? {
|
||||
return c.typeDeserializer.type(proto.isInstanceType(c.typeTable) ?: return null, ConeAttributes.Empty)
|
||||
return c.typeDeserializer.type(proto.isInstanceType(c.typeTable) ?: return null)
|
||||
}
|
||||
|
||||
private fun loadConstant(value: ProtoBuf.Expression.ConstantValue): ConeConstantReference? = when (value) {
|
||||
|
||||
+2
-1
@@ -56,7 +56,7 @@ class FirDeserializationContext(
|
||||
): FirDeserializationContext = FirDeserializationContext(
|
||||
nameResolver, typeTable, versionRequirementTable, session, packageFqName, relativeClassName,
|
||||
FirTypeDeserializer(
|
||||
session, nameResolver, typeTable, typeParameterProtos, typeDeserializer
|
||||
session, nameResolver, typeTable, annotationDeserializer, typeParameterProtos, typeDeserializer
|
||||
),
|
||||
annotationDeserializer, constDeserializer, containerSource,
|
||||
if (capturesTypeParameters) allTypeParameters else emptyList()
|
||||
@@ -129,6 +129,7 @@ class FirDeserializationContext(
|
||||
session,
|
||||
nameResolver,
|
||||
typeTable,
|
||||
annotationDeserializer,
|
||||
typeParameterProtos,
|
||||
null
|
||||
),
|
||||
|
||||
+9
-3
@@ -38,6 +38,7 @@ class FirTypeDeserializer(
|
||||
val session: FirSession,
|
||||
val nameResolver: NameResolver,
|
||||
val typeTable: TypeTable,
|
||||
val annotationDeserializer: AbstractAnnotationDeserializer,
|
||||
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||
val parent: FirTypeDeserializer?
|
||||
) {
|
||||
@@ -78,7 +79,7 @@ class FirTypeDeserializer(
|
||||
val builder = builders[index]
|
||||
builder.apply {
|
||||
proto.upperBoundList.mapTo(bounds) {
|
||||
buildResolvedTypeRef { type = type(it, ConeAttributes.Empty) }
|
||||
buildResolvedTypeRef { type = type(it) }
|
||||
}
|
||||
addDefaultBoundIfNecessary()
|
||||
}.build()
|
||||
@@ -97,6 +98,12 @@ class FirTypeDeserializer(
|
||||
}
|
||||
}
|
||||
|
||||
fun type(proto: ProtoBuf.Type): ConeKotlinType {
|
||||
val annotations = annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||
val attributes = annotations.computeTypeAttributes()
|
||||
return type(proto, attributes)
|
||||
}
|
||||
|
||||
fun type(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeKotlinType {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val lowerBound = simpleType(proto, attributes)
|
||||
@@ -119,7 +126,6 @@ class FirTypeDeserializer(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun FirClassLikeSymbol<*>.typeParameters(): List<FirTypeParameterSymbol> =
|
||||
(fir as? FirTypeParameterRefsOwner)?.typeParameters?.map { it.symbol }.orEmpty()
|
||||
|
||||
@@ -221,7 +227,7 @@ class FirTypeDeserializer(
|
||||
val variance = ProtoEnumFlags.variance(typeArgumentProto.projection)
|
||||
val type = typeArgumentProto.type(typeTable)
|
||||
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("No type recorded", DiagnosticKind.DeserializationError))
|
||||
val coneType = type(type, ConeAttributes.Empty)
|
||||
val coneType = type(type)
|
||||
return coneType.toTypeProjection(variance)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user