diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index 50027605c55..95d567fe815 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -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 diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index 75c62548959..6f6acc34166 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -60,6 +60,7 @@ class FirDeserializationContext( fun childContext( typeParameterProtos: List, + 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, diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index bb6c2cd8352..84ef171ce55 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -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 { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 853ec89f9b5..3179bcf3fcd 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -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 { diff --git a/compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt b/compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt new file mode 100644 index 00000000000..661a865d58b --- /dev/null +++ b/compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt @@ -0,0 +1,27 @@ +// ISSUE: KT-56706 +// MODULE: lib +// FILE: lib.kt +package lib + +abstract class BaseRoot> { + open class BaseNested(val box: V) +} + +// MODULE: main(lib) +// FILE: main.kt +package main +import lib.BaseRoot + +class Foo(val v: String) + +class ImplRoot : BaseRoot() { + + class ImplNested: BaseNested(box = Foo("OK")) { + fun bar(): String { + return BaseNested(box).box.v // K1 doesn't report it, yet message is really strange + // "actual type is main/Foo but lib/BaseRoot.BaseNested<*> was expected" which is also strange, since type of box is main/Foo and V for argument + } + } +} + +fun box(): String = ImplRoot.ImplNested().bar() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 9ee0c751d14..da3c88cae74 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -17581,6 +17581,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); } + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } + @Test @TestMetadata("notFoundClasses.kt") public void testNotFoundClasses() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index eb570f58a32..cefce102f33 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -18511,6 +18511,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes 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 { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3588f216089..66e245599a9 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -14568,6 +14568,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); } + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } + @TestMetadata("notFoundClasses.kt") public void testNotFoundClasses() throws Exception { runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 92c822c8bac..105c9d4ad3e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -13544,6 +13544,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 234a29a9f2d..05b7d03f60a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -13640,6 +13640,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 9381a27f81a..0b5c55e7c17 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -13640,6 +13640,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index b600430e545..36f5f4f5453 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -13640,6 +13640,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java index ac53abc620a..5d00e2a4b01 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java @@ -14858,6 +14858,12 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 7a1907575ba..84027e65885 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -14682,6 +14682,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @Test + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index bcb0a5a16cb..fe3a3cfe863 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -12107,6 +12107,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest public void testFalsePositiveBoundSmartcast() throws Exception { runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt"); } + + @TestMetadata("nestedClassTypeParameterDeserialization.kt") + public void testNestedClassTypeParameterDeserialization() throws Exception { + runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt"); + } } @TestMetadata("compiler/testData/codegen/box/fullJdk")