From 0249e33f3e7f2eaf365de0401bbee86abedd3141 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Wed, 13 Mar 2019 16:08:18 +0300 Subject: [PATCH] IR: add skipExternalProperties flag to PropertiesLowering Same problem as in deafult argument lowering: JVM and JS semantics differ. Same solution: skip in common lowerings, process if needed in platform ones. --- .../kotlin/backend/common/lower/PropertiesLowering.kt | 3 ++- .../src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 e9828181019..c2972eaaa8a 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 @@ -28,6 +28,7 @@ import java.util.* class PropertiesLowering( private val context: BackendContext, private val originOfSyntheticMethodForAnnotations: IrDeclarationOrigin? = null, + private val skipExternalProperties: Boolean = false, private val computeSyntheticMethodName: ((Name) -> String)? = null ) : IrElementTransformerVoid(), FileLoweringPass { override fun lower(irFile: IrFile) { @@ -48,7 +49,7 @@ class PropertiesLowering( private fun lowerProperty(declaration: IrDeclaration, kind: ClassKind): List? = if (declaration is IrProperty) - if (declaration.isEffectivelyExternal()) listOf(declaration) else { + 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) { 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 ba01386a685..83f6cd278f1 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 @@ -240,7 +240,7 @@ private val varargLoweringPhase = makeJsModulePhase( ) private val propertiesLoweringPhase = makeJsModulePhase( - { context -> PropertiesLowering(context) }, + { context -> PropertiesLowering(context, skipExternalProperties = true) }, name = "PropertiesLowering", description = "Move fields and accessors out from its property" )