diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt index d06c1be1107..64fe3a3fb9d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt @@ -229,6 +229,10 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr /* storageManager = */ LockBasedStorageManager.NO_LOCKS ) { override fun getVisibility() = visibility + + override fun getDeclaredTypeParameters(): List { + return oldDescriptor.declaredTypeParameters + } } } } @@ -497,6 +501,19 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr } } + override fun visitField(declaration: IrField): IrField { + val descriptor = mapPropertyDeclaration(declaration.descriptor) + return IrFieldImpl( + declaration.startOffset, declaration.endOffset, + mapDeclarationOrigin(declaration.origin), + descriptor, + context.ir.translateErased(descriptor.type), + declaration.initializer?.transform(this@InlineCopyIr, null) + ).apply { + transformAnnotations(declaration) + } + } + //---------------------------------------------------------------------// override fun visitSimpleFunction(declaration: IrSimpleFunction): IrFunction { diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index e8ce233e76b..edc0239f20d 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2518,6 +2518,11 @@ task inline_defaultArgs(type: RunKonanTest) { source = "codegen/inline/defaultArgs.kt" } +task classDeclarationInsideInline(type: RunKonanTest) { + source = "codegen/inline/classDeclarationInsideInline.kt" + goldValue = "test1: 1.0\n1\ntest2\n" +} + task deserialized_inline0(type: RunKonanTest) { source = "serialization/deserialized_inline0.kt" } diff --git a/backend.native/tests/codegen/inline/classDeclarationInsideInline.kt b/backend.native/tests/codegen/inline/classDeclarationInsideInline.kt new file mode 100644 index 00000000000..aec11473a2e --- /dev/null +++ b/backend.native/tests/codegen/inline/classDeclarationInsideInline.kt @@ -0,0 +1,24 @@ +package codegen.inline.classDeclarationInsideInline + +import kotlin.test.* + +fun f() { + run { + class Test1(val x: T, val y: G) { + override fun toString() = "test1: ${x.toDouble()}" + } + + class Test2(val a: Test1) { + override fun toString() = "test2" + } + + val v = Test2(Test1(1, Test2(Test1(1, 3)))) + println(v.a) + println(v.a.x) + println(v.a.y) + } +} + +@Test fun test() { + f() +}