diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambda.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambda.kt index 7ab4fe3f728..9ca25ff68eb 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambda.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambda.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { val l: suspend () -> Unit = { diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaInsideLambda.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaInsideLambda.kt index c97364f80ae..1d4988ac38b 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaInsideLambda.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaInsideLambda.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { val l: suspend () -> Unit = { diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaWithoutCrossinline.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaWithoutCrossinline.kt index 07d88cb0209..8263d0a6fa6 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaWithoutCrossinline.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerLambdaWithoutCrossinline.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE import COROUTINES_PACKAGE.intrinsics.* import helpers.* diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadness.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadness.kt index 133ebd725db..bbfcfe6c6f7 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadness.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadness.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE interface SuspendRunnable { suspend fun run() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadnessCallSite.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadnessCallSite.kt index aeae8ebcead..b6a9f4d90b5 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadnessCallSite.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerMadnessCallSite.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE interface SuspendRunnable { suspend fun run() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObject.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObject.kt index 1b5f8c1eace..260ee828b76 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObject.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObject.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE interface SuspendRunnable { suspend fun run() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectInsideInnerObject.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectInsideInnerObject.kt index 0c911be8a01..512aeb4cf88 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectInsideInnerObject.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectInsideInnerObject.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE interface SuspendRunnable { suspend fun run() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectSeveralFunctions.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectSeveralFunctions.kt index 19a6b09ae8a..1f7202eeb35 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectSeveralFunctions.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectSeveralFunctions.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE interface SuspendRunnable { suspend fun run1() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectWithoutCapturingCrossinline.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectWithoutCapturingCrossinline.kt index ae1299faf18..a4a3938e3af 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectWithoutCapturingCrossinline.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObjectWithoutCapturingCrossinline.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE import COROUTINES_PACKAGE.intrinsics.* import helpers.* diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/normalInline.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/normalInline.kt index 2c8a7134c5e..392460baefb 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/normalInline.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/normalInline.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { c() diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/numberOfSuspentions.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/numberOfSuspentions.kt index 726b1144468..8ca52ead9b0 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/numberOfSuspentions.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/numberOfSuspentions.kt @@ -4,6 +4,7 @@ // WITH_RUNTIME // WITH_COROUTINES // NO_CHECK_LAMBDA_INLINING +// CHECK_STATE_MACHINE suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { val l: suspend () -> Unit = { c() } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/coroutineTestUtil.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/coroutineTestUtil.kt index 002af54443e..e1710dd329f 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/coroutineTestUtil.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/coroutineTestUtil.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin import org.jetbrains.kotlin.resolve.DescriptorUtils -fun createTextForHelpers(isReleaseCoroutines: Boolean): String { +fun createTextForHelpers(isReleaseCoroutines: Boolean, checkStateMachine: Boolean): String { val coroutinesPackage = if (isReleaseCoroutines) DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString() @@ -76,7 +76,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String { else "" - val checkStateMachine = """ + val checkStateMachineString = """ object StateMachineChecker { private var counter = 0 var finished = false @@ -141,6 +141,6 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String { | $continuationAdapterBody |} | - |$checkStateMachine + |${if (checkStateMachine) checkStateMachineString else ""} """.trimMargin() } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index e19ab9c097e..ad08302ef0d 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -806,9 +806,11 @@ public class KotlinTestUtils { !coroutinesPackage.contains("experimental") && !isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines"); + boolean checkStateMachine = isDirectiveDefined(expectedText, "CHECK_STATE_MACHINE"); + testFiles.add(factory.createFile(supportModule, "CoroutineUtil.kt", - CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines), + CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines, checkStateMachine), directives )); } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 index ee9f87b08de..65f18ee3714 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 @@ -803,9 +803,11 @@ public class KotlinTestUtils { !coroutinesPackage.contains("experimental") && !isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines"); + boolean checkStateMachine = isDirectiveDefined(expectedText, "CHECK_STATE_MACHINE"); + testFiles.add(factory.createFile(supportModule, "CoroutineUtil.kt", - CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines), + CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines, checkStateMachine), directives )); }