From d5c2707c2c571aa1073afff3673ae2072107eff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Tue, 21 Apr 2020 17:23:07 +0200 Subject: [PATCH] JVM IR: Fix corresponding properties in JvmStaticAnnotationLowering --- .../backend/jvm/lower/JvmStaticAnnotationLowering.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt index 3084f6d2672..9fc56cf0117 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.common.runOnFilePostfix import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin +import org.jetbrains.kotlin.backend.jvm.ir.copyCorrespondingPropertyFrom import org.jetbrains.kotlin.backend.jvm.ir.isInCurrentModule import org.jetbrains.kotlin.backend.jvm.ir.replaceThisByStaticReference import org.jetbrains.kotlin.descriptors.Modality @@ -137,14 +138,15 @@ private class SingletonObjectJvmStaticLowering( // dispatch receiver parameter is already null for synthetic property annotation methods jvmStaticFunction.dispatchReceiverParameter?.let { oldDispatchReceiverParameter -> jvmStaticFunction.dispatchReceiverParameter = null - modifyBody(jvmStaticFunction, irClass, oldDispatchReceiverParameter) + jvmStaticFunction.body = jvmStaticFunction.body?.replaceThisByStaticReference( + context.declarationFactory, + irClass, + oldDispatchReceiverParameter + ) } } } - fun modifyBody(irFunction: IrFunction, irClass: IrClass, oldDispatchReceiverParameter: IrValueParameter) { - irFunction.body = irFunction.body?.replaceThisByStaticReference(context.declarationFactory, irClass, oldDispatchReceiverParameter) - } } private fun IrFunction.isJvmStaticInSingleton(): Boolean { @@ -193,7 +195,7 @@ private class MakeCallsStatic( returnType = this@copyRemovingDispatchReceiver.returnType }.also { it.parent = parent - it.correspondingPropertySymbol = correspondingPropertySymbol + it.copyCorrespondingPropertyFrom(this) it.annotations += annotations it.copyParameterDeclarationsFrom(this) it.dispatchReceiverParameter = null