diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt index 8a2fd9517e6..6b320dcc3cf 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt @@ -61,7 +61,12 @@ internal class DeepCopyIrTreeWithSymbolsForInliner( } override fun visitField(declaration: IrField) { - (declaration.descriptor as? WrappedFieldDescriptor)?.bind(declaration) + (declaration.descriptor as WrappedFieldDescriptor).bind(declaration) + declaration.acceptChildrenVoid(this) + } + + override fun visitProperty(declaration: IrProperty) { + (declaration.descriptor as WrappedPropertyDescriptor).bind(declaration) declaration.acceptChildrenVoid(this) } @@ -122,6 +127,9 @@ internal class DeepCopyIrTreeWithSymbolsForInliner( override fun remapDeclaredField(descriptor: PropertyDescriptor) = WrappedFieldDescriptor(descriptor.annotations, descriptor.source) + override fun remapDeclaredProperty(descriptor: PropertyDescriptor) = + WrappedPropertyDescriptor(descriptor.annotations, descriptor.source) + override fun remapDeclaredSimpleFunction(descriptor: FunctionDescriptor) = WrappedSimpleFunctionDescriptor(descriptor.annotations, descriptor.source) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt index 83bb52bb4c9..c5203f6cfa2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt @@ -84,10 +84,7 @@ open class DeepCopySymbolRemapper( override fun visitField(declaration: IrField) { remapSymbol(fields, declaration) { - if (declaration.correspondingProperty == null) - IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredField(it.descriptor)) - else - IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredProperty(it.descriptor)) + IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredField(it.descriptor)) } declaration.acceptChildrenVoid(this) } diff --git a/compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt b/compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt new file mode 100644 index 00000000000..6ef7c86a3b8 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt @@ -0,0 +1,33 @@ +// MODULE: lib +// FILE: lib.kt + +import kotlin.reflect.* + +class Delegate { + var inner = "OK" + operator fun getValue(t: Any?, p: KProperty<*>): String = inner +} + +inline fun foo(b: () -> T): T { + return b() +} + +fun del() = Delegate() + +// MODULE: lib2(lib) +// FILE: lib2.kt + +fun qux() = foo { + val f = object { + val a by del() + } + + f.a +} + +// MODULE: main(lib2) +// FILE: main.kt + +fun box(): String { + return qux() +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 72082e54b29..5bb1fe2611d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -9305,6 +9305,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt"); } + @TestMetadata("insideInlinedObjectMultiModule.kt") + public void testInsideInlinedObjectMultiModule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt"); + } + @TestMetadata("kt4138.kt") public void testKt4138() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index cf48d09410d..27598cc3030 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -9305,6 +9305,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt"); } + @TestMetadata("insideInlinedObjectMultiModule.kt") + public void testInsideInlinedObjectMultiModule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt"); + } + @TestMetadata("kt4138.kt") public void testKt4138() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 9482e59e0bd..6b6dcd2b346 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -9305,6 +9305,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt"); } + @TestMetadata("insideInlinedObjectMultiModule.kt") + public void testInsideInlinedObjectMultiModule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt"); + } + @TestMetadata("kt4138.kt") public void testKt4138() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 3e1ea86095d..d1e8fe5086d 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -7095,6 +7095,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt"); } + @TestMetadata("insideInlinedObjectMultiModule.kt") + public void testInsideInlinedObjectMultiModule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt"); + } + @TestMetadata("kt4138.kt") public void testKt4138() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index f9a1a23c889..c3fe95a08f8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -8180,6 +8180,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt"); } + @TestMetadata("insideInlinedObjectMultiModule.kt") + public void testInsideInlinedObjectMultiModule() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt"); + } + @TestMetadata("kt4138.kt") public void testKt4138() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");