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