From 481bef97994313ebe4dd87cc00920043f70c5f5c Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Tue, 23 Oct 2018 16:08:16 +0300 Subject: [PATCH] JVM_IR. Copy annotations properly in MoveCompanionObjectFieldsLowering --- .../backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt index e45085a35d6..2396c1c24a9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt @@ -123,8 +123,8 @@ class MoveCompanionObjectFieldsLowering(val context: CommonBackendContext) : Cla val variableMap = mutableMapOf() override fun visitVariable(declaration: IrVariable): IrStatement { - val newDescriptor = WrappedVariableDescriptor(declaration.descriptor.annotations, declaration.descriptor.source) if (declaration.parent == oldParent) { + val newDescriptor = WrappedVariableDescriptor(declaration.descriptor.annotations, declaration.descriptor.source) val newVariable = IrVariableImpl( declaration.startOffset, declaration.endOffset, declaration.origin, IrVariableSymbolImpl(newDescriptor), @@ -133,6 +133,8 @@ class MoveCompanionObjectFieldsLowering(val context: CommonBackendContext) : Cla newDescriptor.bind(this) parent = newParent initializer = declaration.initializer + annotations.addAll(declaration.annotations) + } variableMap[declaration] = newVariable return super.visitVariable(newVariable) @@ -181,7 +183,7 @@ class MoveCompanionObjectFieldsLowering(val context: CommonBackendContext) : Cla ).apply { descriptor.bind(this) parent = fieldParent - oldField.annotations.mapTo(annotations) { it } + annotations.addAll(oldField.annotations) } val oldInitializer = oldField.initializer if (oldInitializer != null) {