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_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
val l: suspend () -> Unit = {
@@ -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 = {
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
import COROUTINES_PACKAGE.intrinsics.*
import helpers.*
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable {
suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable {
suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable {
suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable {
suspend fun run()
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
interface SuspendRunnable {
suspend fun run1()
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
import COROUTINES_PACKAGE.intrinsics.*
import helpers.*
@@ -4,6 +4,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// CHECK_STATE_MACHINE
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
c()
@@ -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() }
@@ -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()
}
@@ -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
));
}
@@ -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
));
}