diff --git a/compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt b/compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt new file mode 100644 index 00000000000..bb865ea2294 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt @@ -0,0 +1,32 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST + +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +suspend fun suspendHere(): String { + var z = "fail1" + suspendCoroutineUninterceptedOrReturn { x -> + z = "OK" + x.resume(Unit) + COROUTINE_SUSPENDED + } + return z +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var result = "fail2" + + builder { + result = suspendHere() + } + + return result +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index e85256927c5..0155315008f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -5435,6 +5435,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/beginWithException.kt", "kotlin.coroutines"); } + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index ab3e86672f8..08dd95d94f7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -5435,6 +5435,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/beginWithException.kt", "kotlin.coroutines"); } + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index f419a80aa12..57adfcf9363 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -5435,6 +5435,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/beginWithException.kt", "kotlin.coroutines"); } + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt", "kotlin.coroutines.experimental"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index c87f4c31619..1afc1c0bf58 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -5115,6 +5115,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/beginWithException.kt", "kotlin.coroutines"); } + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 77a50db9ca6..7c7ea1188d1 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5185,6 +5185,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/beginWithException.kt", "kotlin.coroutines"); } + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("capturedVarInSuspendLambda.kt") + public void testCapturedVarInSuspendLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt", "kotlin.coroutines.experimental");