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 88eb5b1998576..84ecf0f5ea068 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 @@ -727,7 +727,7 @@ private val inlineClassUsageLoweringPhase = makeBodyLoweringPhase( ) private val autoboxingTransformerPhase = makeBodyLoweringPhase( - { AutoboxingTransformer(it, shouldCalculateActualTypeForInlinedFunction = true) }, + ::AutoboxingTransformer, name = "AutoboxingTransformer", description = "Insert box/unbox intrinsics" ) 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 dc236f7bbdf23..55de84c67f438 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,10 +31,7 @@ import org.jetbrains.kotlin.ir.util.render // Copied and adapted from Kotlin/Native -abstract class AbstractValueUsageLowering( - val context: JsCommonBackendContext, - private val shouldCalculateActualTypeForInlinedFunction: Boolean = false -) : AbstractValueUsageTransformer(context.irBuiltIns), +abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) : AbstractValueUsageTransformer(context.irBuiltIns), BodyLoweringPass { val icUtils = context.inlineClassesUtils @@ -55,19 +52,11 @@ abstract class AbstractValueUsageLowering( abstract fun IrExpression.useExpressionAsType(actualType: IrType, expectedType: IrType): IrExpression - protected fun IrExpression.getActualType(): IrType = when (this) { + protected fun IrExpression.getActualType() = when (this) { is IrConstructorCall -> symbol.owner.returnType is IrCall -> symbol.owner.realOverrideTarget.returnType is IrGetField -> this.symbol.owner.type - is IrInlinedFunctionBlock -> { - if (shouldCalculateActualTypeForInlinedFunction) { - inlineCall.getActualType() - } else { - this.type - } - } - is IrTypeOperatorCall -> { if (operator == IrTypeOperator.REINTERPRET_CAST) { this.typeOperand @@ -131,10 +120,7 @@ abstract class AbstractValueUsageLowering( ) } -class AutoboxingTransformer( - context: JsCommonBackendContext, - shouldCalculateActualTypeForInlinedFunction: Boolean = false -) : AbstractValueUsageLowering(context, shouldCalculateActualTypeForInlinedFunction) { +class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsageLowering(context) { private var processingReturnStack = mutableListOf() private fun IrExpression.useReturnableExpressionAsType(expectedType: IrType): IrExpression { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java index 239bef27c60d4..a82c916fc0880 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java @@ -796,12 +796,6 @@ public void testAllFilesPresentInCoroutines() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true); } - @Test - @TestMetadata("boxingUnboxingInsideTheSuspendFunction.kt") - public void testBoxingUnboxingInsideTheSuspendFunction() throws Exception { - runTest("js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt"); - } - @Test @TestMetadata("debugStatement.kt") public void testDebugStatement() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsBoxTestGenerated.java index 62ec9fb1d09c8..ca056440fa28c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsBoxTestGenerated.java @@ -860,12 +860,6 @@ public void testAllFilesPresentInCoroutines() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true); } - @Test - @TestMetadata("boxingUnboxingInsideTheSuspendFunction.kt") - public void testBoxingUnboxingInsideTheSuspendFunction() throws Exception { - runTest("js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt"); - } - @Test @TestMetadata("debugStatement.kt") public void testDebugStatement() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.java index f38a26ddbb1b2..a8015be1f760d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.java @@ -860,12 +860,6 @@ public void testAllFilesPresentInCoroutines() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } - @Test - @TestMetadata("boxingUnboxingInsideTheSuspendFunction.kt") - public void testBoxingUnboxingInsideTheSuspendFunction() throws Exception { - runTest("js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt"); - } - @Test @TestMetadata("debugStatement.kt") public void testDebugStatement() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java index b3d1ea80cdc07..116c84b65c322 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java @@ -860,12 +860,6 @@ public void testAllFilesPresentInCoroutines() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true); } - @Test - @TestMetadata("boxingUnboxingInsideTheSuspendFunction.kt") - public void testBoxingUnboxingInsideTheSuspendFunction() throws Exception { - runTest("js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt"); - } - @Test @TestMetadata("debugStatement.kt") public void testDebugStatement() throws Exception { diff --git a/js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt b/js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt deleted file mode 100644 index 0b1284924bb9b..0000000000000 --- a/js/js.translator/testData/box/coroutines/boxingUnboxingInsideTheSuspendFunction.kt +++ /dev/null @@ -1,35 +0,0 @@ -// WITH_STDLIB -// EXPECTED_REACHABLE_NODES: 1292 -// KT-60785 - -import kotlin.coroutines.* -import kotlin.coroutines.intrinsics.* - -value class SomeValue(val a: String) { - override fun toString() = when (a) { - "fa" -> "O" - "il" -> "K" - else -> "" - } -} - -suspend fun foo() = mapOf(SomeValue("fa") to SomeValue("il")) - -fun builder(c: suspend () -> Unit) { - c.startCoroutine(object : Continuation { - override val context = EmptyCoroutineContext - override fun resumeWith(result: Result) {} - }) -} - -fun box(): String { - var result = "" - - builder { - for ((k, v) in foo()) { - result += "$k$v" - } - } - - return result -}