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.
This commit is contained in:
Anton Bannykh
2019-03-13 16:08:18 +03:00
parent 9a56b0e6d6
commit 0249e33f3e
2 changed files with 3 additions and 2 deletions
@@ -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<IrDeclaration>? =
if (declaration is IrProperty)
if (declaration.isEffectivelyExternal()) listOf(declaration) else {
if (skipExternalProperties && declaration.isEffectivelyExternal()) listOf(declaration) else {
ArrayList<IrDeclaration>(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) {
@@ -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"
)