K2: fix logic for supertypes annotation deserialization
This commit is contained in:
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
}
|
||||
|
||||
public abstract interface Foo<T : R|@R|test/A|() kotlin/Number|> : R|java/io/Serializable| {
|
||||
public abstract interface Foo<T : R|@R|test/A|() kotlin/Number|> : R|@R|test/A|() java/io/Serializable| {
|
||||
public abstract fun <E, F : R|E|> bar(): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
|
||||
+1
-8
@@ -123,14 +123,7 @@ fun deserializeClassToSymbol(
|
||||
val typeDeserializer = context.typeDeserializer
|
||||
val classDeserializer = context.memberDeserializer
|
||||
|
||||
val superTypesDeserialized = classProto.supertypes(context.typeTable).map { supertypeProto ->
|
||||
typeDeserializer.simpleType(supertypeProto, ConeAttributes.Empty)
|
||||
}
|
||||
|
||||
superTypesDeserialized.mapNotNullTo(superTypeRefs) {
|
||||
if (it == null) return@mapNotNullTo null
|
||||
buildResolvedTypeRef { type = it }
|
||||
}
|
||||
classProto.supertypes(context.typeTable).mapTo(superTypeRefs, typeDeserializer::typeRef)
|
||||
|
||||
addDeclarations(
|
||||
classProto.functionList.map {
|
||||
|
||||
+2
-8
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.computeTypeAttributes
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
@@ -635,11 +634,6 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
}.toList()
|
||||
}
|
||||
|
||||
private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef {
|
||||
return buildResolvedTypeRef {
|
||||
annotations += context.annotationDeserializer.loadTypeAnnotations(this@toTypeRef, context.nameResolver)
|
||||
val attributes = annotations.computeTypeAttributes(context.session)
|
||||
type = context.typeDeserializer.type(this@toTypeRef, attributes)
|
||||
}
|
||||
}
|
||||
private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef =
|
||||
context.typeDeserializer.typeRef(this)
|
||||
}
|
||||
|
||||
+15
-6
@@ -106,13 +106,22 @@ class FirTypeDeserializer(
|
||||
}
|
||||
}
|
||||
|
||||
fun type(proto: ProtoBuf.Type): ConeKotlinType {
|
||||
val annotations = annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||
val attributes = annotations.computeTypeAttributes(moduleData.session)
|
||||
return type(proto, attributes)
|
||||
fun typeRef(proto: ProtoBuf.Type): FirTypeRef {
|
||||
return buildResolvedTypeRef {
|
||||
annotations += annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||
type = type(proto, annotations.computeTypeAttributes(moduleData.session))
|
||||
}
|
||||
}
|
||||
|
||||
fun type(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeKotlinType {
|
||||
private fun attributesFromAnnotations(proto: ProtoBuf.Type) =
|
||||
annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||
.computeTypeAttributes(moduleData.session)
|
||||
|
||||
fun type(proto: ProtoBuf.Type): ConeKotlinType {
|
||||
return type(proto, attributesFromAnnotations(proto))
|
||||
}
|
||||
|
||||
private fun type(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeKotlinType {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val lowerBound = simpleType(proto, attributes)
|
||||
val upperBound = simpleType(proto.flexibleUpperBound(typeTable)!!, attributes)
|
||||
@@ -145,7 +154,7 @@ class FirTypeDeserializer(
|
||||
fun FirClassLikeSymbol<*>.typeParameters(): List<FirTypeParameterSymbol> =
|
||||
(fir as? FirTypeParameterRefsOwner)?.typeParameters?.map { it.symbol }.orEmpty()
|
||||
|
||||
fun simpleType(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeSimpleKotlinType? {
|
||||
private fun simpleType(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeSimpleKotlinType? {
|
||||
val constructor = typeSymbol(proto) ?: return null
|
||||
if (constructor is ConeTypeParameterLookupTag) {
|
||||
return ConeTypeParameterTypeImpl(constructor, isNullable = proto.nullable).let {
|
||||
|
||||
Reference in New Issue
Block a user