[FIR] Fix captured type parameters propagation in deserialization
This commit is contained in:
Vendored
+3
-2
@@ -27,8 +27,8 @@ public final class Generic<T> : R|kotlin/Any| {
|
|||||||
public final class InnerGeneric<A, B> : R|kotlin/Any| {
|
public final class InnerGeneric<A, B> : R|kotlin/Any| {
|
||||||
public constructor<A, B>(): R|test/InnerGeneric<A, B>|
|
public constructor<A, B>(): R|test/InnerGeneric<A, B>|
|
||||||
|
|
||||||
public final inner class Inner<in C, D : R|A|> : R|kotlin/Any| {
|
public final inner class Inner<in C, D : R|A|, A, B> : R|kotlin/Any| {
|
||||||
public constructor<in C, D : R|A|>(): R|test/InnerGeneric.Inner<C, D>|
|
public constructor<in C, D : R|A|>(): R|test/InnerGeneric.Inner<C, D, A, B>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,3 +38,4 @@ public final class Simple : R|kotlin/Any| {
|
|||||||
public constructor(): R|test/Simple|
|
public constructor(): R|test/Simple|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -3,21 +3,22 @@ public final class Outer<E, F> : R|kotlin/Any| {
|
|||||||
|
|
||||||
public constructor<E, F>(): R|test/Outer<E, F>|
|
public constructor<E, F>(): R|test/Outer<E, F>|
|
||||||
|
|
||||||
public final inner class Inner<G, H> : R|kotlin/Any| {
|
public final inner class Inner<G, H, E, F> : R|kotlin/Any| {
|
||||||
public constructor<G, H>(): R|test/Outer.Inner<G, H>|
|
public constructor<G, H>(): R|test/Outer.Inner<G, H, E, F>|
|
||||||
|
|
||||||
public final inner class Inner3<I> : R|kotlin/Any| {
|
public final inner class Inner3<I, G, H, E, F> : R|kotlin/Any| {
|
||||||
public final fun foo(x: R|test/Outer.Inner<G, kotlin/Int, kotlin/String, F>|, y: R|test/Outer.Inner<E, kotlin/Double, E, F>|, z: R|test/Outer.Inner.Inner3<kotlin/Double, G, kotlin/Int, kotlin/String, F>|, w: R|test/Outer.Inner.Inner3<*, G, H, E, F>|): R|kotlin/Unit|
|
public final fun foo(x: R|test/Outer.Inner<G, kotlin/Int, kotlin/String, F>|, y: R|test/Outer.Inner<E, kotlin/Double, E, F>|, z: R|test/Outer.Inner.Inner3<kotlin/Double, G, kotlin/Int, kotlin/String, F>|, w: R|test/Outer.Inner.Inner3<*, G, H, E, F>|): R|kotlin/Unit|
|
||||||
|
|
||||||
public constructor<I>(): R|test/Outer.Inner.Inner3<I>|
|
public constructor<I>(): R|test/Outer.Inner.Inner3<I, G, H, E, F>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final inner class Inner2 : R|kotlin/Any| {
|
public final inner class Inner2<E, F> : R|kotlin/Any| {
|
||||||
public constructor(): R|test/Outer.Inner2|
|
public constructor(): R|test/Outer.Inner2<E, F>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -1,18 +1,18 @@
|
|||||||
public final class A<TA> : R|kotlin/Any| {
|
public final class A<TA> : R|kotlin/Any| {
|
||||||
public constructor<TA>(): R|test/A<TA>|
|
public constructor<TA>(): R|test/A<TA>|
|
||||||
|
|
||||||
public final inner class B<TB> : R|kotlin/Any| {
|
public final inner class B<TB, TA> : R|kotlin/Any| {
|
||||||
public constructor<TB>(): R|test/A.B<TB>|
|
public constructor<TB>(): R|test/A.B<TB, TA>|
|
||||||
|
|
||||||
public final inner class C<TC> : R|kotlin/Any| {
|
public final inner class C<TC, TB, TA> : R|kotlin/Any| {
|
||||||
public constructor<TC>(): R|test/A.B.C<TC>|
|
public constructor<TC>(): R|test/A.B.C<TC, TB, TA>|
|
||||||
|
|
||||||
public final inner class D<TD> : R|kotlin/Any| {
|
public final inner class D<TD, TC, TB, TA> : R|kotlin/Any| {
|
||||||
public final fun bar(ta: R|TA|, tb: R|TB|, tc: R|TC|, td: R|TD|): R|test/A.B.C.D<TD, TC, TB, TA>|
|
public final fun bar(ta: R|TA|, tb: R|TB|, tc: R|TC|, td: R|TD|): R|test/A.B.C.D<TD, TC, TB, TA>|
|
||||||
|
|
||||||
public final fun <P1, P2, P3, P4> foo(p1: R|P1|, p2: R|P2|, p3: R|P3|, p4: R|P4|): R|kotlin/Nothing|
|
public final fun <P1, P2, P3, P4> foo(p1: R|P1|, p2: R|P2|, p3: R|P3|, p4: R|P4|): R|kotlin/Nothing|
|
||||||
|
|
||||||
public constructor<TD>(): R|test/A.B.C.D<TD>|
|
public constructor<TD>(): R|test/A.B.C.D<TD, TC, TB, TA>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-2
@@ -1,9 +1,10 @@
|
|||||||
public final class InnerClassReferencesOuterTP<P> : R|kotlin/Any| {
|
public final class InnerClassReferencesOuterTP<P> : R|kotlin/Any| {
|
||||||
public constructor<P>(): R|test/InnerClassReferencesOuterTP<P>|
|
public constructor<P>(): R|test/InnerClassReferencesOuterTP<P>|
|
||||||
|
|
||||||
public final inner class Inner<Q : R|P|> : R|kotlin/Any| {
|
public final inner class Inner<Q : R|P|, P> : R|kotlin/Any| {
|
||||||
public constructor<Q : R|P|>(): R|test/InnerClassReferencesOuterTP.Inner<Q>|
|
public constructor<Q : R|P|>(): R|test/InnerClassReferencesOuterTP.Inner<Q, P>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,7 @@
|
|||||||
public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
|
public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
|
||||||
public constructor<P>(): R|test/MembersReferenceOuterTP<P>|
|
public constructor<P>(): R|test/MembersReferenceOuterTP<P>|
|
||||||
|
|
||||||
public final inner class Inner : R|kotlin/Any| {
|
public final inner class Inner<P> : R|kotlin/Any| {
|
||||||
public final fun <Q : R|P|> f(): R|kotlin/Unit|
|
public final fun <Q : R|P|> f(): R|kotlin/Unit|
|
||||||
|
|
||||||
public final fun g(p: R|P|): R|P|
|
public final fun g(p: R|P|): R|P|
|
||||||
@@ -12,8 +12,9 @@ public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
|
|||||||
public final val <Q : R|P|> R|Q|.w: R|Q|
|
public final val <Q : R|P|> R|Q|.w: R|Q|
|
||||||
public get(): R|Q|
|
public get(): R|Q|
|
||||||
|
|
||||||
public constructor(): R|test/MembersReferenceOuterTP.Inner|
|
public constructor(): R|test/MembersReferenceOuterTP.Inner<P>|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -75,7 +75,8 @@ fun deserializeClassToSymbol(
|
|||||||
classProto.typeParameterList,
|
classProto.typeParameterList,
|
||||||
nameResolver,
|
nameResolver,
|
||||||
TypeTable(classProto.typeTable),
|
TypeTable(classProto.typeTable),
|
||||||
classId.relativeClassName
|
classId.relativeClassName,
|
||||||
|
status.isInner
|
||||||
) ?: FirDeserializationContext.createForClass(
|
) ?: FirDeserializationContext.createForClass(
|
||||||
classId, classProto, nameResolver, session,
|
classId, classProto, nameResolver, session,
|
||||||
defaultAnnotationDeserializer ?: FirBuiltinAnnotationDeserializer(session),
|
defaultAnnotationDeserializer ?: FirBuiltinAnnotationDeserializer(session),
|
||||||
@@ -90,7 +91,10 @@ fun deserializeClassToSymbol(
|
|||||||
this.symbol = symbol
|
this.symbol = symbol
|
||||||
|
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
|
|
||||||
typeParameters += context.typeDeserializer.ownTypeParameters.map { it.fir }
|
typeParameters += context.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||||
|
if (status.isInner)
|
||||||
|
typeParameters += parentContext?.allTypeParameters?.map { buildOuterClassTypeParameterRef { this.symbol = it } }.orEmpty()
|
||||||
// annotations += context.annotationDeserializer.loadClassAnnotations(classProto, context.nameResolver)
|
// annotations += context.annotationDeserializer.loadClassAnnotations(classProto, context.nameResolver)
|
||||||
|
|
||||||
val typeDeserializer = context.typeDeserializer
|
val typeDeserializer = context.typeDeserializer
|
||||||
|
|||||||
+12
-3
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.getName
|
import org.jetbrains.kotlin.serialization.deserialization.getName
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||||
|
|
||||||
class FirDeserializationContext(
|
class FirDeserializationContext(
|
||||||
val nameResolver: NameResolver,
|
val nameResolver: NameResolver,
|
||||||
@@ -39,19 +40,24 @@ class FirDeserializationContext(
|
|||||||
val typeDeserializer: FirTypeDeserializer,
|
val typeDeserializer: FirTypeDeserializer,
|
||||||
val annotationDeserializer: AbstractAnnotationDeserializer,
|
val annotationDeserializer: AbstractAnnotationDeserializer,
|
||||||
val containerSource: DeserializedContainerSource?,
|
val containerSource: DeserializedContainerSource?,
|
||||||
|
outerTypeParameters: List<FirTypeParameterSymbol>,
|
||||||
val components: FirDeserializationComponents
|
val components: FirDeserializationComponents
|
||||||
) {
|
) {
|
||||||
|
val allTypeParameters: List<FirTypeParameterSymbol> =
|
||||||
|
typeDeserializer.ownTypeParameters + outerTypeParameters
|
||||||
|
|
||||||
fun childContext(
|
fun childContext(
|
||||||
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||||
nameResolver: NameResolver = this.nameResolver,
|
nameResolver: NameResolver = this.nameResolver,
|
||||||
typeTable: TypeTable = this.typeTable,
|
typeTable: TypeTable = this.typeTable,
|
||||||
relativeClassName: FqName? = this.relativeClassName
|
relativeClassName: FqName? = this.relativeClassName,
|
||||||
|
capturesTypeParameters: Boolean = true
|
||||||
): 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, typeParameterProtos, typeDeserializer
|
||||||
),
|
),
|
||||||
annotationDeserializer, containerSource, components
|
annotationDeserializer, containerSource, if (capturesTypeParameters) allTypeParameters else emptyList(), components
|
||||||
)
|
)
|
||||||
|
|
||||||
val memberDeserializer: FirMemberDeserializer = FirMemberDeserializer(this)
|
val memberDeserializer: FirMemberDeserializer = FirMemberDeserializer(this)
|
||||||
@@ -118,6 +124,7 @@ class FirDeserializationContext(
|
|||||||
),
|
),
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
containerSource,
|
containerSource,
|
||||||
|
emptyList(),
|
||||||
FirDeserializationComponents()
|
FirDeserializationComponents()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -284,7 +291,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
}
|
}
|
||||||
this.symbol = symbol
|
this.symbol = symbol
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
this.typeParameters += typeParameters.map { buildConstructedClassTypeParameterRef { this.symbol = it.symbol } }
|
this.typeParameters +=
|
||||||
|
typeParameters.filterIsInstance<FirTypeParameter>()
|
||||||
|
.map { buildConstructedClassTypeParameterRef { this.symbol = it.symbol } }
|
||||||
valueParameters += local.memberDeserializer.valueParameters(
|
valueParameters += local.memberDeserializer.valueParameters(
|
||||||
proto.valueParameterList, addDefaultValue = classBuilder.symbol.classId == StandardClassIds.Enum
|
proto.valueParameterList, addDefaultValue = classBuilder.symbol.classId == StandardClassIds.Enum
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user