Add tests for case when result of tail-call suspend function returning
Unit is not Unit. #KT-34703 Fixed
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var c: Continuation<*>? = null
|
||||
|
||||
suspend fun <T> tx(lambda: () -> T): T = suspendCoroutine { c = it; lambda() }
|
||||
|
||||
object Dummy
|
||||
|
||||
suspend fun suspect() {
|
||||
tx { Dummy }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: Any? = null
|
||||
builder {
|
||||
res = suspect()
|
||||
}
|
||||
|
||||
(c as? Continuation<Dummy>)?.resume(Dummy)
|
||||
|
||||
return if (res != Unit) "$res" else "OK"
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.reflect.full.callSuspend
|
||||
import kotlin.reflect.KCallable
|
||||
|
||||
var c: Continuation<*>? = null
|
||||
|
||||
suspend fun <T> tx(lambda: () -> T): T = suspendCoroutine { c = it; lambda() }
|
||||
|
||||
object Dummy
|
||||
|
||||
suspend fun suspect() {
|
||||
tx { Dummy }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: Any? = null
|
||||
builder {
|
||||
res = (::suspect as KCallable<*>).callSuspend()
|
||||
}
|
||||
|
||||
(c as? Continuation<Dummy>)?.resume(Dummy)
|
||||
|
||||
return if (res != Unit) "$res" else "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user