From a6d5c02d9bb17bc5d16442ba1ec4c1a6d268947d Mon Sep 17 00:00:00 2001 From: pyos Date: Mon, 5 Oct 2020 14:20:34 +0200 Subject: [PATCH] JVM_IR: add a transformChildren call to PropertyReferenceLowering #KT-42354 Fixed --- .../kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java | 5 +++++ .../kotlin/backend/jvm/lower/PropertyReferenceLowering.kt | 4 +--- .../box/callableReference/property/inReceiverOfAnother.kt | 7 +++++++ .../kotlin/codegen/BlackBoxCodegenTestGenerated.java | 5 +++++ .../kotlin/codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java | 5 +++++ .../test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../js/test/semantics/JsCodegenBoxTestGenerated.java | 5 +++++ 9 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 76ad6058507..8ccd84d03fa 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -2976,6 +2976,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt index 77a6e347e7a..f5006fe59fd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt @@ -66,9 +66,6 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class private val IrMemberAccessExpression<*>.field: IrFieldSymbol? get() = (this as? IrPropertyReference)?.field - private val IrSimpleFunction.signature: String - get() = context.methodSignatureMapper.mapSignatureSkipGeneric(collectRealOverrides().first()).toString() - // Plain Java fields do not have a getter, but can be referenced nonetheless. The signature should be the one // that a getter would have, if it existed. private val IrField.signature: String @@ -216,6 +213,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class cachedKProperty(expression) private fun cachedKProperty(expression: IrCallableReference<*>): IrExpression { + expression.transformChildrenVoid() if (expression.origin != IrStatementOrigin.PROPERTY_REFERENCE_FOR_DELEGATE) return createSpecializedKProperty(expression) diff --git a/compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt b/compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt new file mode 100644 index 00000000000..da300db3a28 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt @@ -0,0 +1,7 @@ +var x = "OK" + +class C(init: () -> String) { + val value = init() +} + +fun box() = C(::x)::value.get() diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 05c48befa66..84c7916566a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2996,6 +2996,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 22a216d5722..db9360b1dbd 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2996,6 +2996,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 0becd10427b..b8f9a48f834 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2976,6 +2976,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 2009d1fb431..b859db67a28 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -2341,6 +2341,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.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 606d31fc2cd..700309a277c 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 @@ -2341,6 +2341,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.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 68ed0d86378..224f4fd3207 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 @@ -2341,6 +2341,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt"); } + @TestMetadata("inReceiverOfAnother.kt") + public void testInReceiverOfAnother() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/property/inReceiverOfAnother.kt"); + } + @TestMetadata("invokePropertyReference.kt") public void testInvokePropertyReference() throws Exception { runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");