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:
+2
-1
@@ -28,6 +28,7 @@ import java.util.*
|
|||||||
class PropertiesLowering(
|
class PropertiesLowering(
|
||||||
private val context: BackendContext,
|
private val context: BackendContext,
|
||||||
private val originOfSyntheticMethodForAnnotations: IrDeclarationOrigin? = null,
|
private val originOfSyntheticMethodForAnnotations: IrDeclarationOrigin? = null,
|
||||||
|
private val skipExternalProperties: Boolean = false,
|
||||||
private val computeSyntheticMethodName: ((Name) -> String)? = null
|
private val computeSyntheticMethodName: ((Name) -> String)? = null
|
||||||
) : IrElementTransformerVoid(), FileLoweringPass {
|
) : IrElementTransformerVoid(), FileLoweringPass {
|
||||||
override fun lower(irFile: IrFile) {
|
override fun lower(irFile: IrFile) {
|
||||||
@@ -48,7 +49,7 @@ class PropertiesLowering(
|
|||||||
|
|
||||||
private fun lowerProperty(declaration: IrDeclaration, kind: ClassKind): List<IrDeclaration>? =
|
private fun lowerProperty(declaration: IrDeclaration, kind: ClassKind): List<IrDeclaration>? =
|
||||||
if (declaration is IrProperty)
|
if (declaration is IrProperty)
|
||||||
if (declaration.isEffectivelyExternal()) listOf(declaration) else {
|
if (skipExternalProperties && declaration.isEffectivelyExternal()) listOf(declaration) else {
|
||||||
ArrayList<IrDeclaration>(4).apply {
|
ArrayList<IrDeclaration>(4).apply {
|
||||||
// JvmFields in a companion object refer to companion's owners and should not be generated within companion.
|
// 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 (kind != ClassKind.ANNOTATION_CLASS && declaration.backingField?.parent == declaration.parent) {
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ private val varargLoweringPhase = makeJsModulePhase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val propertiesLoweringPhase = makeJsModulePhase(
|
private val propertiesLoweringPhase = makeJsModulePhase(
|
||||||
{ context -> PropertiesLowering(context) },
|
{ context -> PropertiesLowering(context, skipExternalProperties = true) },
|
||||||
name = "PropertiesLowering",
|
name = "PropertiesLowering",
|
||||||
description = "Move fields and accessors out from its property"
|
description = "Move fields and accessors out from its property"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user