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|
|
public abstract fun <E, F : R|E|> bar(): R|kotlin/Unit|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-8
@@ -123,14 +123,7 @@ fun deserializeClassToSymbol(
|
|||||||
val typeDeserializer = context.typeDeserializer
|
val typeDeserializer = context.typeDeserializer
|
||||||
val classDeserializer = context.memberDeserializer
|
val classDeserializer = context.memberDeserializer
|
||||||
|
|
||||||
val superTypesDeserialized = classProto.supertypes(context.typeTable).map { supertypeProto ->
|
classProto.supertypes(context.typeTable).mapTo(superTypeRefs, typeDeserializer::typeRef)
|
||||||
typeDeserializer.simpleType(supertypeProto, ConeAttributes.Empty)
|
|
||||||
}
|
|
||||||
|
|
||||||
superTypesDeserialized.mapNotNullTo(superTypeRefs) {
|
|
||||||
if (it == null) return@mapNotNullTo null
|
|
||||||
buildResolvedTypeRef { type = it }
|
|
||||||
}
|
|
||||||
|
|
||||||
addDeclarations(
|
addDeclarations(
|
||||||
classProto.functionList.map {
|
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.ConeLookupTagBasedType
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
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.coneType
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
@@ -635,11 +634,6 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef {
|
private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef =
|
||||||
return buildResolvedTypeRef {
|
context.typeDeserializer.typeRef(this)
|
||||||
annotations += context.annotationDeserializer.loadTypeAnnotations(this@toTypeRef, context.nameResolver)
|
|
||||||
val attributes = annotations.computeTypeAttributes(context.session)
|
|
||||||
type = context.typeDeserializer.type(this@toTypeRef, attributes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-6
@@ -106,13 +106,22 @@ class FirTypeDeserializer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun type(proto: ProtoBuf.Type): ConeKotlinType {
|
fun typeRef(proto: ProtoBuf.Type): FirTypeRef {
|
||||||
val annotations = annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
return buildResolvedTypeRef {
|
||||||
val attributes = annotations.computeTypeAttributes(moduleData.session)
|
annotations += annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||||
return type(proto, attributes)
|
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()) {
|
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||||
val lowerBound = simpleType(proto, attributes)
|
val lowerBound = simpleType(proto, attributes)
|
||||||
val upperBound = simpleType(proto.flexibleUpperBound(typeTable)!!, attributes)
|
val upperBound = simpleType(proto.flexibleUpperBound(typeTable)!!, attributes)
|
||||||
@@ -145,7 +154,7 @@ 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()
|
||||||
|
|
||||||
fun simpleType(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeSimpleKotlinType? {
|
private fun simpleType(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeSimpleKotlinType? {
|
||||||
val constructor = typeSymbol(proto) ?: return null
|
val constructor = typeSymbol(proto) ?: return null
|
||||||
if (constructor is ConeTypeParameterLookupTag) {
|
if (constructor is ConeTypeParameterLookupTag) {
|
||||||
return ConeTypeParameterTypeImpl(constructor, isNullable = proto.nullable).let {
|
return ConeTypeParameterTypeImpl(constructor, isNullable = proto.nullable).let {
|
||||||
|
|||||||
Reference in New Issue
Block a user