Do not generate StateMachineChecker if CHECK_STATE_MACHINE directive is

not present.
Otherwise, since it uses suspend functions, it breaks IR tests.
This commit is contained in:
Ilmir Usmanov
2019-03-14 15:21:44 +03:00
parent 7956ef18b2
commit c68413b953
14 changed files with 20 additions and 5 deletions
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
val l: suspend () -> Unit = { val l: suspend () -> Unit = {
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
val l: suspend () -> Unit = { val l: suspend () -> Unit = {
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
import COROUTINES_PACKAGE.intrinsics.* import COROUTINES_PACKAGE.intrinsics.*
import helpers.* import helpers.*
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable { interface SuspendRunnable {
suspend fun run() suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable { interface SuspendRunnable {
suspend fun run() suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable { interface SuspendRunnable {
suspend fun run() suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable { interface SuspendRunnable {
suspend fun run() suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable { interface SuspendRunnable {
suspend fun run1() suspend fun run1()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
import COROUTINES_PACKAGE.intrinsics.* import COROUTINES_PACKAGE.intrinsics.*
import helpers.* import helpers.*
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
c() c()
@@ -4,6 +4,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING // NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) { suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
val l: suspend () -> Unit = { c() } val l: suspend () -> Unit = { c() }
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
fun createTextForHelpers(isReleaseCoroutines: Boolean): String { fun createTextForHelpers(isReleaseCoroutines: Boolean, checkStateMachine: Boolean): String {
val coroutinesPackage = val coroutinesPackage =
if (isReleaseCoroutines) if (isReleaseCoroutines)
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString() DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString()
@@ -76,7 +76,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
else else
"" ""
val checkStateMachine = """ val checkStateMachineString = """
object StateMachineChecker { object StateMachineChecker {
private var counter = 0 private var counter = 0
var finished = false var finished = false
@@ -141,6 +141,6 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
| $continuationAdapterBody | $continuationAdapterBody
|} |}
| |
|$checkStateMachine |${if (checkStateMachine) checkStateMachineString else ""}
""".trimMargin() """.trimMargin()
} }
@@ -806,9 +806,11 @@ public class KotlinTestUtils {
!coroutinesPackage.contains("experimental") && !coroutinesPackage.contains("experimental") &&
!isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines"); !isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines");
boolean checkStateMachine = isDirectiveDefined(expectedText, "CHECK_STATE_MACHINE");
testFiles.add(factory.createFile(supportModule, testFiles.add(factory.createFile(supportModule,
"CoroutineUtil.kt", "CoroutineUtil.kt",
CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines), CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines, checkStateMachine),
directives directives
)); ));
} }
@@ -803,9 +803,11 @@ public class KotlinTestUtils {
!coroutinesPackage.contains("experimental") && !coroutinesPackage.contains("experimental") &&
!isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines"); !isDirectiveDefined(expectedText, "!LANGUAGE: -ReleaseCoroutines");
boolean checkStateMachine = isDirectiveDefined(expectedText, "CHECK_STATE_MACHINE");
testFiles.add(factory.createFile(supportModule, testFiles.add(factory.createFile(supportModule,
"CoroutineUtil.kt", "CoroutineUtil.kt",
CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines), CoroutineTestUtilKt.createTextForHelpers(isReleaseCoroutines, checkStateMachine),
directives directives
)); ));
} }