From 0702b88bf3d6f49aa969556bd6d6de71be520765 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Mon, 13 May 2019 15:27:10 +0300 Subject: [PATCH] [IR BE] Update parents in ArrayConstructorLowering --- .../backend/common/lower/ArrayConstructorLowering.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt index fed0d94a27b..7cdb4d88763 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt @@ -62,7 +62,8 @@ class ArrayConstructorLowering(val context: CommonBackendContext) : IrElementTra // (and similar for primitive arrays) val size = expression.getValueArgument(0)!!.transform(this, null) val invokable = expression.getValueArgument(1)!!.transform(this, null) - return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol).irBlock(expression.startOffset, expression.endOffset) { + val scope = currentScope!!.scope + return context.createIrBuilder(scope.scopeOwnerSymbol).irBlock(expression.startOffset, expression.endOffset) { val index = irTemporaryVar(irInt(0)) val sizeVar = irTemporary(size) val result = irTemporary(irCall(sizeConstructor, expression.type).apply { @@ -91,6 +92,10 @@ class ArrayConstructorLowering(val context: CommonBackendContext) : IrElementTra } } +irGet(result) + }.also { + // Some parents of local declarations are not updated during ad-hoc inlining + // TODO: Remove when generic inliner is used + it.patchDeclarationParents(scope.getLocalDeclarationParent()) } }