diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt index 1798946f5a1..5f81729f6ec 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt @@ -30,6 +30,7 @@ class PropertiesLowering( private val context: BackendContext, private val originOfSyntheticMethodForAnnotations: IrDeclarationOrigin? = null, private val skipExternalProperties: Boolean = false, + private val generateAnnotationFields: Boolean = false, private val computeSyntheticMethodName: ((Name) -> String)? = null ) : IrElementTransformerVoid(), FileLoweringPass { override fun lower(irFile: IrFile) { @@ -53,7 +54,7 @@ class PropertiesLowering( if (skipExternalProperties && declaration.isEffectivelyExternal()) listOf(declaration) else { ArrayList(4).apply { // JvmFields in a companion object refer to companion's owners and should not be generated within companion. - if (kind != ClassKind.ANNOTATION_CLASS && declaration.backingField?.parent == declaration.parent) { + if (generateAnnotationFields || (kind != ClassKind.ANNOTATION_CLASS && declaration.backingField?.parent == declaration.parent)) { addIfNotNull(declaration.backingField) } addIfNotNull(declaration.getter) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt index dae90a7e1a7..93ca8397797 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt @@ -248,7 +248,7 @@ private val varargLoweringPhase = makeJsModulePhase( ) private val propertiesLoweringPhase = makeJsModulePhase( - { context -> PropertiesLowering(context, skipExternalProperties = true) }, + { context -> PropertiesLowering(context, skipExternalProperties = true, generateAnnotationFields = true) }, name = "PropertiesLowering", description = "Move fields and accessors out from its property" )