diff --git a/compiler/testData/codegen/boxInline/smap/crossroutines.kt b/compiler/testData/codegen/boxInline/smap/crossroutines.kt new file mode 100644 index 00000000000..46e8ea6234b --- /dev/null +++ b/compiler/testData/codegen/boxInline/smap/crossroutines.kt @@ -0,0 +1,146 @@ +// IGNORE_BACKEND_MULTI_MODULE: JVM_IR +// WITH_RUNTIME +// FILE: 1.kt + +package test + +interface SuspendRunnable { + suspend fun run() +} + +inline suspend fun inlineMe1(crossinline c: suspend () -> Unit): SuspendRunnable = + object : SuspendRunnable { + override suspend fun run() { + c() + } + } + +inline suspend fun inlineMe2(crossinline c: suspend () -> Unit): suspend () -> Unit = + { + c() + } + +// FILE: 2.kt + +import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* +import test.* + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(object: Continuation { + override val context = EmptyCoroutineContext + override fun resumeWith(result: Result) { + result.getOrThrow() + } + }) +} + +fun box(): String { + var res = "" + builder { + inlineMe1 { + res += "O" + }.run() + inlineMe2 { + res += "K" + }() + } + return res +} + +// FILE: 1.smap +SMAP +1.kt +Kotlin +*S Kotlin +*F ++ 1 1.kt +test/_1Kt$inlineMe2$2 +*L +1#1,23:1 +*E + +SMAP +1.kt +Kotlin +*S Kotlin +*F ++ 1 1.kt +test/_1Kt$inlineMe1$2 +*L +1#1,23:1 +*E + +SMAP +1.kt +Kotlin +*S Kotlin +*F ++ 1 1.kt +test/_1Kt$inlineMe1$2$run$1 +*L +1#1,23:1 +*E + +// FILE: 2.smap +SMAP +2.kt +Kotlin +*S Kotlin +*F ++ 1 2.kt +_2Kt$builder$1 +*L +1#1,29:1 +*E + +SMAP +2.kt +Kotlin +*S Kotlin +*F ++ 1 2.kt +_2Kt$box$1 ++ 2 1.kt +test/_1Kt +*L +1#1,29:1 +12#2,5:30 +19#2,3:35 +*E +*S KotlinDebug +*F ++ 1 2.kt +_2Kt$box$1 +*L +19#1,5:30 +22#1,3:35 +*E + +SMAP +1.kt +Kotlin +*S Kotlin +*F ++ 1 1.kt +test/_1Kt$inlineMe2$2 ++ 2 2.kt +_2Kt$box$1 +*L +1#1,23:1 +23#2,2:24 +*E + +SMAP +1.kt +Kotlin +*S Kotlin +*F ++ 1 1.kt +test/_1Kt$inlineMe1$2 ++ 2 2.kt +_2Kt$box$1 +*L +1#1,23:1 +20#2,2:24 +*E \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 4859f7a5161..9a6f3a7d74e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -3238,6 +3238,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/smap/classFromDefaultPackage.kt"); } + @TestMetadata("crossroutines.kt") + public void testCrossroutines() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/crossroutines.kt"); + } + @TestMetadata("defaultFunction.kt") public void testDefaultFunction() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index d98263dd48d..6e3b3ef4583 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3238,6 +3238,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/smap/classFromDefaultPackage.kt"); } + @TestMetadata("crossroutines.kt") + public void testCrossroutines() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/crossroutines.kt"); + } + @TestMetadata("defaultFunction.kt") public void testDefaultFunction() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 579cf47e0e1..67ec45f4487 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3238,6 +3238,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/smap/classFromDefaultPackage.kt"); } + @TestMetadata("crossroutines.kt") + public void testCrossroutines() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/crossroutines.kt"); + } + @TestMetadata("defaultFunction.kt") public void testDefaultFunction() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 9ef73f9c6f0..dcff22a83dc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3238,6 +3238,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/smap/classFromDefaultPackage.kt"); } + @TestMetadata("crossroutines.kt") + public void testCrossroutines() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/crossroutines.kt"); + } + @TestMetadata("defaultFunction.kt") public void testDefaultFunction() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");