[K/JS] Fix corutines build for 1.9.20
This reverts commit f0d6471a8bcbdfc52ddc840a6383032ef86976d1.
This commit is contained in:
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesInInlineFunc
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesInInlineLambdasLowering
|
import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesInInlineLambdasLowering
|
||||||
import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering
|
import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.*
|
import org.jetbrains.kotlin.backend.common.phaser.*
|
||||||
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.*
|
import org.jetbrains.kotlin.ir.backend.js.lower.*
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering
|
import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering
|
import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering
|
||||||
@@ -22,6 +23,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.AddContinuationToFunc
|
|||||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendArityStoreLowering
|
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendArityStoreLowering
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLowering
|
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLowering
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.inline.*
|
import org.jetbrains.kotlin.ir.backend.js.lower.inline.*
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsGenerationGranularity
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||||
import org.jetbrains.kotlin.ir.interpreter.IrInterpreterConfiguration
|
import org.jetbrains.kotlin.ir.interpreter.IrInterpreterConfiguration
|
||||||
@@ -736,7 +738,7 @@ private val inlineClassUsageLoweringPhase = makeBodyLoweringPhase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val autoboxingTransformerPhase = makeBodyLoweringPhase(
|
private val autoboxingTransformerPhase = makeBodyLoweringPhase(
|
||||||
{ AutoboxingTransformer(it, shouldCalculateActualTypeForInlinedFunction = true) },
|
::AutoboxingTransformer,
|
||||||
name = "AutoboxingTransformer",
|
name = "AutoboxingTransformer",
|
||||||
description = "Insert box/unbox intrinsics"
|
description = "Insert box/unbox intrinsics"
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-17
@@ -31,10 +31,7 @@ import org.jetbrains.kotlin.ir.util.render
|
|||||||
|
|
||||||
// Copied and adapted from Kotlin/Native
|
// Copied and adapted from Kotlin/Native
|
||||||
|
|
||||||
abstract class AbstractValueUsageLowering(
|
abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) : AbstractValueUsageTransformer(context.irBuiltIns),
|
||||||
val context: JsCommonBackendContext,
|
|
||||||
private val shouldCalculateActualTypeForInlinedFunction: Boolean = false
|
|
||||||
) : AbstractValueUsageTransformer(context.irBuiltIns),
|
|
||||||
BodyLoweringPass {
|
BodyLoweringPass {
|
||||||
|
|
||||||
val icUtils = context.inlineClassesUtils
|
val icUtils = context.inlineClassesUtils
|
||||||
@@ -55,19 +52,11 @@ abstract class AbstractValueUsageLowering(
|
|||||||
|
|
||||||
abstract fun IrExpression.useExpressionAsType(actualType: IrType, expectedType: IrType): IrExpression
|
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 IrConstructorCall -> symbol.owner.returnType
|
||||||
is IrCall -> symbol.owner.realOverrideTarget.returnType
|
is IrCall -> symbol.owner.realOverrideTarget.returnType
|
||||||
is IrGetField -> this.symbol.owner.type
|
is IrGetField -> this.symbol.owner.type
|
||||||
|
|
||||||
is IrInlinedFunctionBlock -> {
|
|
||||||
if (shouldCalculateActualTypeForInlinedFunction) {
|
|
||||||
inlineCall.getActualType()
|
|
||||||
} else {
|
|
||||||
this.type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is IrTypeOperatorCall -> {
|
is IrTypeOperatorCall -> {
|
||||||
if (operator == IrTypeOperator.REINTERPRET_CAST) {
|
if (operator == IrTypeOperator.REINTERPRET_CAST) {
|
||||||
this.typeOperand
|
this.typeOperand
|
||||||
@@ -131,10 +120,7 @@ abstract class AbstractValueUsageLowering(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoboxingTransformer(
|
class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsageLowering(context) {
|
||||||
context: JsCommonBackendContext,
|
|
||||||
shouldCalculateActualTypeForInlinedFunction: Boolean = false
|
|
||||||
) : AbstractValueUsageLowering(context, shouldCalculateActualTypeForInlinedFunction) {
|
|
||||||
private var processingReturnStack = mutableListOf<IrReturn>()
|
private var processingReturnStack = mutableListOf<IrReturn>()
|
||||||
|
|
||||||
private fun IrExpression.useReturnableExpressionAsType(expectedType: IrType): IrExpression {
|
private fun IrExpression.useReturnableExpressionAsType(expectedType: IrType): IrExpression {
|
||||||
|
|||||||
-6
@@ -872,12 +872,6 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
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
|
@Test
|
||||||
@TestMetadata("debugStatement.kt")
|
@TestMetadata("debugStatement.kt")
|
||||||
public void testDebugStatement() throws Exception {
|
public void testDebugStatement() throws Exception {
|
||||||
|
|||||||
-6
@@ -872,12 +872,6 @@ public class FirJsES6BoxTestGenerated extends AbstractFirJsES6BoxTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
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
|
@Test
|
||||||
@TestMetadata("debugStatement.kt")
|
@TestMetadata("debugStatement.kt")
|
||||||
public void testDebugStatement() throws Exception {
|
public void testDebugStatement() throws Exception {
|
||||||
|
|||||||
-6
@@ -872,12 +872,6 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
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
|
@Test
|
||||||
@TestMetadata("debugStatement.kt")
|
@TestMetadata("debugStatement.kt")
|
||||||
public void testDebugStatement() throws Exception {
|
public void testDebugStatement() throws Exception {
|
||||||
|
|||||||
-6
@@ -872,12 +872,6 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
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
|
@Test
|
||||||
@TestMetadata("debugStatement.kt")
|
@TestMetadata("debugStatement.kt")
|
||||||
public void testDebugStatement() throws Exception {
|
public void testDebugStatement() throws Exception {
|
||||||
|
|||||||
-35
@@ -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<Unit> {
|
|
||||||
override val context = EmptyCoroutineContext
|
|
||||||
override fun resumeWith(result: Result<Unit>) {}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fun box(): String {
|
|
||||||
var result = ""
|
|
||||||
|
|
||||||
builder {
|
|
||||||
for ((k, v) in foo()) {
|
|
||||||
result += "$k$v"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user