diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt index 13b081cb65303..4b0e577fb17aa 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt @@ -34,7 +34,8 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid * TODO: consider making this visitor non-recursive to make it more general. */ abstract class AbstractValueUsageTransformer( - protected val irBuiltIns: IrBuiltIns + protected val irBuiltIns: IrBuiltIns, + private val replaceTypesInsideInlinedFunctionBlock: Boolean = false ) : IrElementTransformerVoid() { protected open fun IrExpression.useAs(type: IrType): IrExpression = this @@ -120,7 +121,7 @@ abstract class AbstractValueUsageTransformer( } override fun visitContainerExpression(expression: IrContainerExpression): IrExpression { - if (expression is IrInlinedFunctionBlock) { + if (!replaceTypesInsideInlinedFunctionBlock && expression is IrInlinedFunctionBlock) { expression.transformChildrenVoid(this) return expression } 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 f9d995bd10861..316bf563674a9 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 @@ -526,8 +526,7 @@ private val innerClassConstructorCallsLoweringPhase = makeBodyLoweringPhase( private val suspendFunctionsLoweringPhase = makeBodyLoweringPhase( ::JsSuspendFunctionsLowering, name = "SuspendFunctionsLowering", - description = "Transform suspend functions into CoroutineImpl instance and build state machine", - prerequisite = setOf(returnableBlockLoweringPhase) + description = "Transform suspend functions into CoroutineImpl instance and build state machine" ) private val addContinuationToNonLocalSuspendFunctionsLoweringPhase = makeDeclarationTransformerPhase( @@ -739,7 +738,7 @@ private val inlineClassUsageLoweringPhase = makeBodyLoweringPhase( ) private val autoboxingTransformerPhase = makeBodyLoweringPhase( - ::AutoboxingTransformer, + { AutoboxingTransformer(it, replaceTypesInsideInlinedFunctionBlock = true) }, name = "AutoboxingTransformer", description = "Insert box/unbox intrinsics" ) @@ -922,7 +921,6 @@ val loweringList = listOf( enumUsageLoweringPhase, externalEnumUsageLoweringPhase, enumEntryRemovalLoweringPhase, - returnableBlockLoweringPhase, suspendFunctionsLoweringPhase, propertyReferenceLoweringPhase, interopCallableReferenceLoweringPhase, @@ -930,6 +928,7 @@ val loweringList = listOf( addContinuationToNonLocalSuspendFunctionsLoweringPhase, addContinuationToLocalSuspendFunctionsLoweringPhase, addContinuationToFunctionCallsLoweringPhase, + returnableBlockLoweringPhase, rangeContainsLoweringPhase, forLoopsLoweringPhase, primitiveCompanionLoweringPhase, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt index 873e686e2618d..48ae8a876e8e2 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt @@ -31,7 +31,10 @@ import org.jetbrains.kotlin.ir.util.render // Copied and adapted from Kotlin/Native -abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) : AbstractValueUsageTransformer(context.irBuiltIns), +abstract class AbstractValueUsageLowering( + val context: JsCommonBackendContext, + replaceTypesInsideInlinedFunctionBlock: Boolean = false +) : AbstractValueUsageTransformer(context.irBuiltIns, replaceTypesInsideInlinedFunctionBlock), BodyLoweringPass { val icUtils = context.inlineClassesUtils @@ -120,7 +123,8 @@ abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) : ) } -class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsageLowering(context) { +class AutoboxingTransformer(context: JsCommonBackendContext, replaceTypesInsideInlinedFunctionBlock: Boolean = false) : + AbstractValueUsageLowering(context, replaceTypesInsideInlinedFunctionBlock) { private var processingReturnStack = mutableListOf() private fun IrExpression.useReturnableExpressionAsType(expectedType: IrType): IrExpression { diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt index 29fe34ea6c019..d9d34f0414681 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt @@ -1,5 +1,6 @@ // WITH_STDLIB // WITH_COROUTINES +// IGNORE_BACKEND: JS_IR, JS_IR_ES6 import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/releaseIntercepted.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/releaseIntercepted.kt index 454d6d298f772..8049e9f10f2c6 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/releaseIntercepted.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/releaseIntercepted.kt @@ -1,4 +1,5 @@ // WITH_STDLIB +// IGNORE_BACKEND: JS_IR, JS_IR_ES6 import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/debug/localVariables/suspend/inlineLocalsStateMachineTransform.kt b/compiler/testData/debug/localVariables/suspend/inlineLocalsStateMachineTransform.kt index 529e197492063..ca5295d3aa89f 100644 --- a/compiler/testData/debug/localVariables/suspend/inlineLocalsStateMachineTransform.kt +++ b/compiler/testData/debug/localVariables/suspend/inlineLocalsStateMachineTransform.kt @@ -36,5 +36,7 @@ suspend fun box() { // test.kt:12 doResume: // test.kt:8 h: $completion=$boxCOROUTINE$0 // test.kt:4 doResume: +// test.kt:5 doResume: x=41:number // test.kt:4 doResume: x=41:number +// test.kt:5 doResume: x=41:number, x=41:number // test.kt:19 doResume: x=41:number, x=41:number diff --git a/compiler/testData/debug/localVariables/suspend/mergeLvt.kt b/compiler/testData/debug/localVariables/suspend/mergeLvt.kt index fdf60a907fadc..2ca9ab5a80606 100644 --- a/compiler/testData/debug/localVariables/suspend/mergeLvt.kt +++ b/compiler/testData/debug/localVariables/suspend/mergeLvt.kt @@ -68,6 +68,5 @@ suspend fun box() { // test.kt:12 : // test.kt:38 doResume: // test.kt:38 doResume: -// test.kt:38 doResume: // test.kt:27 doResume: // test.kt:28 doResume: a=Unit diff --git a/compiler/testData/debug/localVariables/suspend/nestedInsideSuspendUnintercepted.kt b/compiler/testData/debug/localVariables/suspend/nestedInsideSuspendUnintercepted.kt index 85248d18082ee..1d23f9f09036f 100644 --- a/compiler/testData/debug/localVariables/suspend/nestedInsideSuspendUnintercepted.kt +++ b/compiler/testData/debug/localVariables/suspend/nestedInsideSuspendUnintercepted.kt @@ -71,6 +71,5 @@ suspend fun box() { // test.kt:7 id: obj=2:number // test.kt:38 doResume: c=1:number, b=2:number // test.kt:38 doResume: c=1:number, b=2:number -// test.kt:39 doResume: c=1:number, b=2:number // test.kt:30 doResume: c=1:number, b=2:number // test.kt:31 doResume: c=1:number, b=2:number, a=Unit diff --git a/compiler/testData/debug/localVariables/suspend/nestedSuspendUnintercepted.kt b/compiler/testData/debug/localVariables/suspend/nestedSuspendUnintercepted.kt index 47802d8c24b43..c135da1465cc4 100644 --- a/compiler/testData/debug/localVariables/suspend/nestedSuspendUnintercepted.kt +++ b/compiler/testData/debug/localVariables/suspend/nestedSuspendUnintercepted.kt @@ -42,6 +42,5 @@ suspend fun box() { // EXPECTATIONS JS_IR // test.kt:31 doResume: // test.kt:31 doResume: -// test.kt:31 doResume: // test.kt:22 doResume: // test.kt:23 doResume: a=Unit diff --git a/compiler/testData/debug/localVariables/suspend/nestedSuspendUninterceptedWithDeepLambdaCall.kt b/compiler/testData/debug/localVariables/suspend/nestedSuspendUninterceptedWithDeepLambdaCall.kt index fb7c4c3c43760..5c8c0c4de00dc 100644 --- a/compiler/testData/debug/localVariables/suspend/nestedSuspendUninterceptedWithDeepLambdaCall.kt +++ b/compiler/testData/debug/localVariables/suspend/nestedSuspendUninterceptedWithDeepLambdaCall.kt @@ -103,6 +103,5 @@ suspend fun box() { // test.kt:7 id: obj=5:number // test.kt:44 doResume: b=2:number, e=5:number // test.kt:44 doResume: b=2:number, e=5:number -// test.kt:45 doResume: b=2:number, e=5:number // test.kt:33 doResume: b=2:number, e=5:number // test.kt:37 doResume: b=2:number, e=5:number, result=Unit diff --git a/js/js.translator/testData/box/coercion/unitMaterializationOnCall.kt b/js/js.translator/testData/box/coercion/unitMaterializationOnCall.kt index 53a280aa22bfa..7781cca67832f 100644 --- a/js/js.translator/testData/box/coercion/unitMaterializationOnCall.kt +++ b/js/js.translator/testData/box/coercion/unitMaterializationOnCall.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JS_IR, JS_IR_ES6 // DONT_TARGET_EXACT_BACKEND: JS var demoCallCounter = 0 diff --git a/js/js.translator/testData/lineNumbers/coroutine.kt b/js/js.translator/testData/lineNumbers/coroutine.kt index d4c8a23589c78..47f7236673828 100644 --- a/js/js.translator/testData/lineNumbers/coroutine.kt +++ b/js/js.translator/testData/lineNumbers/coroutine.kt @@ -15,4 +15,4 @@ suspend fun bar(): Unit { } // LINES(JS): 39 4 4 4 7 5 5 45 45 5 93 45 5 5 6 4 4 4 9 15 9 9 9 * 9 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14 * 9 15 9 9 9 9 -// LINES(JS_IR): 4 4 * 9 9 * 4 * 4 * 19 5 5 * 19 * 19 19 * 19 19 * 6 6 * 19 * 19 * 4 * 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 14 14 15 15 +// LINES(JS_IR): 4 4 * 93 3 45 45 7 7 6 9 9 * 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 14 14 15 15