Deserialize experimental coroutines as suspend functions/types

but deprecate them for now.
Promote stub version.
 #KT-25623: Fixed
This commit is contained in:
Ilmir Usmanov
2018-07-19 21:49:28 +03:00
parent 88a5eb24d5
commit fa9653c3d2
16 changed files with 228 additions and 127 deletions
@@ -1,5 +1,7 @@
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
// TODO: Unmute when automatic conversion experimental <-> release will be implemented
// IGNORE_BACKEND: JVM, JS, NATIVE, JVM_IR, JS_IR
import kotlin.coroutines.experimental.*
fun builder1(c: suspend () -> String): String {
@@ -39,11 +41,11 @@ fun ok(continuation: Continuation<String>): Any? {
}
fun box(): String {
if (builder1(::ok) != "OK") return "FAIL 1"
if (builder1 { cont: Continuation<String> -> "OK" } != "OK") return "FAIL 2"
if (builder1(fun (cont: Continuation<String>): Any? = "OK") != "OK") return "FAIL 3"
if (builder2 { cont: Continuation<String> -> this + "K" } != "OK") return "FAIL 5"
if (builder2(fun String.(cont: Continuation<String>): Any? = this + "K") != "OK") return "FAIL 6"
// if (builder1(::ok) != "OK") return "FAIL 1"
// if (builder1 { cont: Continuation<String> -> "OK" } != "OK") return "FAIL 2"
// if (builder1(fun (cont: Continuation<String>): Any? = "OK") != "OK") return "FAIL 3"
//
// if (builder2 { cont: Continuation<String> -> this + "K" } != "OK") return "FAIL 5"
// if (builder2(fun String.(cont: Continuation<String>): Any? = this + "K") != "OK") return "FAIL 6"
return "OK"
}
@@ -1,5 +1,7 @@
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
// TODO: Unmute when automatic conversion experimental <-> release will be implemented
// IGNORE_BACKEND: JVM, JS, NATIVE, JVM_IR, JS_IR
val dummy1: suspend () -> String = { "OK" }
val dummy2: suspend String.() -> String = { this + "K" }
@@ -10,17 +12,17 @@ val dummy3: suspend String.(String) -> String = { s -> this + s }
import kotlin.coroutines.experimental.*
fun box(): String {
val continuation = object : Continuation<String> {
override val context = EmptyCoroutineContext
override fun resume(value: String) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
}
if (dummy1(continuation) != "OK") return "FAIL 1"
if ("O".dummy2(continuation) != "OK") return "FAIL 2"
if ("O".dummy3("K", continuation) != "OK") return "FAIL 3"
// val continuation = object : Continuation<String> {
// override val context = EmptyCoroutineContext
// override fun resume(value: String) {
// }
//
// override fun resumeWithException(exception: Throwable) {
// throw exception
// }
// }
// if (dummy1(continuation) != "OK") return "FAIL 1"
// if ("O".dummy2(continuation) != "OK") return "FAIL 2"
// if ("O".dummy3("K", continuation) != "OK") return "FAIL 3"
return "OK"
}
@@ -1,5 +1,7 @@
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
// TODO: Unmute when automatic conversion experimental <-> release will be implemented
// IGNORE_BACKEND: JVM, JS, NATIVE, JVM_IR, JS_IR
import kotlin.coroutines.experimental.*
fun (suspend () -> String).builder(): String {
@@ -25,8 +27,8 @@ fun ok(continuation: Continuation<String>): Any? {
}
fun box(): String {
if ((::ok).builder() != "OK") return "FAIL 1"
if (({ cont: Continuation<String> -> "OK" }).builder() != "OK") return "FAIL 2"
if ((fun (cont: Continuation<String>): Any? = "OK").builder() != "OK") return "FAIL 3"
// if ((::ok).builder() != "OK") return "FAIL 1"
// if (({ cont: Continuation<String> -> "OK" }).builder() != "OK") return "FAIL 2"
// if ((fun (cont: Continuation<String>): Any? = "OK").builder() != "OK") return "FAIL 3"
return "OK"
}
@@ -1,5 +1,7 @@
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
// TODO: Unmute when automatic conversion experimental <-> release will be implemented
// IGNORE_BACKEND: JVM, JS, NATIVE, JVM_IR, JS_IR
suspend fun dummy() = "OK"
@@ -29,19 +31,19 @@ class WithInner {
import kotlin.coroutines.experimental.*
fun box(): String {
val continuation = object : Continuation<String> {
override val context = EmptyCoroutineContext
override fun resume(value: String) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
}
if (dummy(continuation) != "OK") return "FAIL 1"
if ("O".dummy(continuation) != "OK") return "FAIL 2"
if ("O".dummy("K", continuation) != "OK") return "FAIL 3"
if (C().dummy(continuation) != "OK") return "FAIL 4"
if (WithNested.Nested().dummy(continuation) != "OK") return "FAIL 5"
if (WithInner().Inner().dummy(continuation) != "OK") return "FAIL 6"
// val continuation = object : Continuation<String> {
// override val context = EmptyCoroutineContext
// override fun resume(value: String) {
// }
// override fun resumeWithException(exception: Throwable) {
// throw exception
// }
// }
// if (dummy(continuation) != "OK") return "FAIL 1"
// if ("O".dummy(continuation) != "OK") return "FAIL 2"
// if ("O".dummy("K", continuation) != "OK") return "FAIL 3"
// if (C().dummy(continuation) != "OK") return "FAIL 4"
// if (WithNested.Nested().dummy(continuation) != "OK") return "FAIL 5"
// if (WithInner().Inner().dummy(continuation) != "OK") return "FAIL 6"
return "OK"
}