From e147993ff22e57fbc5e5d490c6c16014ad3fa31e Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Fri, 28 Feb 2020 16:39:33 +0700 Subject: [PATCH] Avoid IR node duplication when lowering interop constant access --- .../kotlin/backend/konan/lower/InteropLowering.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt index 29fa257f2b4..96367d6aaeb 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt @@ -899,10 +899,14 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi ?.takeIf { it.isConst } ?: return null - return constantProperty.backingField + val irConstant = (constantProperty.backingField ?.initializer ?.expression - ?: error("Constant property ${constantProperty.name} has no initializer!") + ?: error("Constant property ${constantProperty.name} has no initializer!")) + as IrConst<*> + + // Avoid node duplication + return irConstant.copy() } override fun visitCall(expression: IrCall): IrExpression {