FIR deserializer: handle class type parameters properly
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2476c0299f
commit
853167a24d
+3
-13
@@ -7,9 +7,8 @@ package org.jetbrains.kotlin.fir.deserialization
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||||
@@ -21,8 +20,6 @@ import org.jetbrains.kotlin.metadata.deserialization.supertypes
|
|||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.getName
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
|
|
||||||
fun deserializeClassToSymbol(
|
fun deserializeClassToSymbol(
|
||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
@@ -46,15 +43,13 @@ fun deserializeClassToSymbol(
|
|||||||
Flags.IS_DATA.get(classProto.flags),
|
Flags.IS_DATA.get(classProto.flags),
|
||||||
Flags.IS_INLINE_CLASS.get(classProto.flags)
|
Flags.IS_INLINE_CLASS.get(classProto.flags)
|
||||||
).apply {
|
).apply {
|
||||||
for (typeParameter in classProto.typeParameterList) {
|
|
||||||
typeParameters += createTypeParameterSymbol(nameResolver.getName(typeParameter.name), session).fir
|
|
||||||
}
|
|
||||||
//addAnnotationsFrom(classProto) ? TODO
|
|
||||||
|
|
||||||
val context =
|
val context =
|
||||||
parentContext?.childContext(classProto.typeParameterList, nameResolver, TypeTable(classProto.typeTable))
|
parentContext?.childContext(classProto.typeParameterList, nameResolver, TypeTable(classProto.typeTable))
|
||||||
?: FirDeserializationContext
|
?: FirDeserializationContext
|
||||||
.createForClass(classId, classProto, nameResolver, session)
|
.createForClass(classId, classProto, nameResolver, session)
|
||||||
|
typeParameters += context.typeDeserializer.ownTypeParameters.map { it.firUnsafe() }
|
||||||
|
//addAnnotationsFrom(classProto) ? TODO
|
||||||
|
|
||||||
val typeDeserializer = context.typeDeserializer
|
val typeDeserializer = context.typeDeserializer
|
||||||
val classDeserializer = context.memberDeserializer
|
val classDeserializer = context.memberDeserializer
|
||||||
@@ -91,8 +86,3 @@ fun deserializeClassToSymbol(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTypeParameterSymbol(name: Name, session: FirSession): FirTypeParameterSymbol {
|
|
||||||
val firSymbol = FirTypeParameterSymbol()
|
|
||||||
FirTypeParameterImpl(session, null, firSymbol, name, variance = Variance.INVARIANT, isReified = false)
|
|
||||||
return firSymbol
|
|
||||||
}
|
|
||||||
|
|||||||
-6
@@ -195,12 +195,6 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTypeParameterSymbol(name: Name): FirTypeParameterSymbol {
|
|
||||||
val firSymbol = FirTypeParameterSymbol()
|
|
||||||
FirTypeParameterImpl(c.session, null, firSymbol, name, variance = Variance.INVARIANT, isReified = false)
|
|
||||||
return firSymbol
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun valueParameters(
|
private fun valueParameters(
|
||||||
valueParameters: List<ProtoBuf.ValueParameter>
|
valueParameters: List<ProtoBuf.ValueParameter>
|
||||||
): List<FirValueParameter> {
|
): List<FirValueParameter> {
|
||||||
|
|||||||
Reference in New Issue
Block a user