From af98720720b1c9c38c8cbe75e87a91991a77110a Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 7 Oct 2020 18:56:55 +0200 Subject: [PATCH] JVM_IR: move MoveOrCopyCompanionObjectFields down a bit More specifically, it should be done *just before* JvmPropertiesLowering, as walking the IR tree between them will result in visiting the moved backing fields twice (once via the companion's parent, once via the IrProperty). Ideally, this group of 3 lowerings should be merged into 1 as they are completely inseparable, but this is slightly harder to do properly. #KT-42527 Fixed --- .../src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt index 5e0ad2ab2ce..8869ef67103 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt @@ -288,12 +288,14 @@ private val jvmFilePhases = listOf( lateinitDeclarationLoweringPhase, lateinitUsageLoweringPhase, - moveOrCopyCompanionObjectFieldsPhase, inlineCallableReferenceToLambdaPhase, functionReferencePhase, suspendLambdaPhase, propertyReferencePhase, constPhase, + // TODO: merge the next three phases together, as visitors behave incorrectly between them + // (backing fields moved out of companion objects are reachable by two paths): + moveOrCopyCompanionObjectFieldsPhase, propertiesPhase, remapObjectFieldAccesses, anonymousObjectSuperConstructorPhase,