From 2918e6578634f628c94a291325aad2f73599c79c Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Wed, 1 Mar 2017 15:37:28 +0300 Subject: [PATCH] Do not create KProperties field if there is no delegated properties. --- .../backend/konan/lower/DelegationLowering.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt index bad27a526ec..10b02e99038 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt @@ -122,7 +122,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa val kPropertiesField = createKPropertiesFieldDescriptor(irFile.packageFragmentDescriptor, genericArrayType.replace(kPropertyImplType)) - irFile.transformChildrenVoid(object : IrElementTransformerVoid() { override fun visitFunction(declaration: IrFunction): IrStatement { return super.visitFunction(declaration) @@ -180,11 +179,13 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa }) - irFile.declarations.add(0, IrFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, - DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION, - kPropertiesField, - IrExpressionBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, - context.createArrayOfExpression(kPropertyImplType, kProperties)))) + if (kProperties.size > 0) { + irFile.declarations.add(0, IrFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, + DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION, + kPropertiesField, + IrExpressionBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, + context.createArrayOfExpression(kPropertyImplType, kProperties)))) + } } private object DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION :