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 39b473dab0d..f041d0db6f0 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 @@ -13997,6 +13997,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/genericJavaProperty.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() throws Exception { diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt index 7b5831af082..601a7e4bb44 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceDelegationLowering.kt @@ -145,6 +145,7 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont }.apply { parent = oldField.parent initializer = context.irFactory.createExpressionBody(it) + correspondingPropertySymbol = oldField.correspondingPropertySymbol } } val originalThis = parentAsClass.thisReceiver diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt new file mode 100644 index 00000000000..96bc9dacf67 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt @@ -0,0 +1,14 @@ +// WITH_STDLIB + +class Z(val x: String = "OK") + +operator fun Z.getValue(x: Any?, y: Any?): Z = this + +class O { + companion object { + val instance: Z by Z() + val y by instance::x + } +} + +fun box(): String = O.y diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt new file mode 100644 index 00000000000..5e5c1b608c6 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt @@ -0,0 +1,18 @@ +// WITH_STDLIB + +class Z(var x: String = "Fail") + +operator fun Z.getValue(x: Any?, y: Any?): Z = this +operator fun Z.setValue(x: Any?, y: Any?, value: Z) { this.x = value.x } + +interface O { + companion object { + val instance: Z by Z() + var y by instance::x + } +} + +fun box(): String { + O.y = "OK" + return O.y +} diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt new file mode 100644 index 00000000000..e3590713051 --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB + +class Z(val x: String = "OK") + +operator fun Z.getValue(x: Any?, y: Any?): Z = this + +object O { + val instance: Z by Z() + val y by instance::x +} + +fun box(): String = O.y 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 2e839cef670..a60948b58f0 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 @@ -13919,6 +13919,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/genericJavaProperty.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() 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 deca6df6b23..69302e5b6cb 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 @@ -13997,6 +13997,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/genericJavaProperty.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() 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 f1300725537..f1b821ba8dc 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11336,6 +11336,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/genericJavaProperty.kt"); } + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @TestMetadata("mutable.kt") public void testMutable() throws Exception { runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/mutable.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 6f274594053..7f5ea9e7dce 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 @@ -10663,6 +10663,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/custom.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() throws Exception { 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 a1caeb339bc..6cca9905548 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 @@ -10705,6 +10705,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/custom.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java index 377dd1d4227..706c431e414 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java @@ -14148,6 +14148,24 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest { runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/genericJavaProperty.kt"); } + @Test + @TestMetadata("kt49793_companionObject.kt") + public void testKt49793_companionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_companionObject.kt"); + } + + @Test + @TestMetadata("kt49793_interfaceCompanionObject.kt") + public void testKt49793_interfaceCompanionObject() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt"); + } + + @Test + @TestMetadata("kt49793_object.kt") + public void testKt49793_object() throws Exception { + runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_object.kt"); + } + @Test @TestMetadata("mutable.kt") public void testMutable() throws Exception {