Skip to content

Commit 3d3d9cd

Browse files
zhelenskiySpace Team
authored andcommitted
[IR] Move JvmUpgradeCallableReferences before SharedVariablesLowering
#KT-74383
1 parent 08d70d2 commit 3d3d9cd

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SharedVariablesLowering.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf
5151
* println(x.element)
5252
* }
5353
*/
54-
class SharedVariablesLowering(val context: LoweringContext) : BodyLoweringPass {
54+
open class SharedVariablesLowering(val context: LoweringContext, val skipRichCallables: Boolean = true) : BodyLoweringPass {
5555
override fun lower(irBody: IrBody, container: IrDeclaration) {
5656
SharedVariablesTransformer(irBody, container).lowerSharedVariables()
5757
}
@@ -87,8 +87,8 @@ class SharedVariablesLowering(val context: LoweringContext) : BodyLoweringPass {
8787
val toSkip = runIf(param.isInlineParameter() && !param.isCrossinline) {
8888
when (arg) {
8989
is IrFunctionExpression -> arg.function
90-
is IrRichFunctionReference -> arg.invokeFunction
91-
is IrRichPropertyReference -> arg.getterFunction
90+
is IrRichFunctionReference if skipRichCallables -> arg.invokeFunction
91+
is IrRichPropertyReference if skipRichCallables -> arg.getterFunction
9292
else -> null
9393
}
9494
}

compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLoweringPhases.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ private val jvmFilePhases = createFilePhases(
7474
::AssertionLowering,
7575
::JvmReturnableBlockLowering,
7676
::SingletonReferencesLowering,
77-
::SharedVariablesLowering,
78-
7977
::JvmUpgradeCallableReferences,
78+
::JvmSharedVariablesLowering,
79+
8080
::JvmInventNamesForLocalFunctions,
8181
::JvmLocalDeclarationsLowering,
8282
::JvmLocalDeclarationPopupLowering,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2010-2025 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.backend.jvm.lower
7+
8+
import org.jetbrains.kotlin.backend.common.lower.SharedVariablesLowering
9+
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
10+
11+
class JvmSharedVariablesLowering(context: JvmBackendContext) : SharedVariablesLowering(context, skipRichCallables = false)

0 commit comments

Comments
 (0)