K2: Fix deserialization of upper bound of type parameter in nested class

Previously, containingDeclarationSymbol for V was set to the outer class
BaseRoot, so its upper bounds was computed to the ones from TNested
at org.jetbrains.kotlin.fir.resolve.calls.CreateFreshTypeVariableSubstitutorStageKt.getTypeParameterFromExpandedClass

^KT-56706 Fixed
This commit is contained in:
Denis.Zharkov
2023-02-17 18:24:23 +01:00
committed by Space Team
parent 9f51d3fbeb
commit 0c9fad87c3
15 changed files with 100 additions and 2 deletions
@@ -85,11 +85,12 @@ fun deserializeClassToSymbol(
val context =
parentContext?.childContext(
classProto.typeParameterList,
containingDeclarationSymbol = symbol,
nameResolver,
TypeTable(classProto.typeTable),
classId.relativeClassName,
containerSource,
symbol,
outerClassSymbol = symbol,
annotationDeserializer,
if (status.isCompanion) {
parentContext.constDeserializer
@@ -60,6 +60,7 @@ class FirDeserializationContext(
fun childContext(
typeParameterProtos: List<ProtoBuf.TypeParameter>,
containingDeclarationSymbol: FirBasedSymbol<*>,
nameResolver: NameResolver = this.nameResolver,
typeTable: TypeTable = this.typeTable,
relativeClassName: FqName? = this.relativeClassName,
@@ -68,7 +69,6 @@ class FirDeserializationContext(
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
constDeserializer: FirConstDeserializer = this.constDeserializer,
capturesTypeParameters: Boolean = true,
containingDeclarationSymbol: FirBasedSymbol<*>? = this.outerClassSymbol
): FirDeserializationContext = FirDeserializationContext(
nameResolver,
typeTable,
@@ -18511,6 +18511,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
}
@Test
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
public void testNestedClassTypeParameterDeserialization() throws Exception {
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
}
@Test
@TestMetadata("noSymbolForIntRangeIterator.kt")
public void testNoSymbolForIntRangeIterator() throws Exception {
@@ -18511,6 +18511,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
}
@Test
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
public void testNestedClassTypeParameterDeserialization() throws Exception {
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
}
@Test
@TestMetadata("noSymbolForIntRangeIterator.kt")
public void testNoSymbolForIntRangeIterator() throws Exception {