Add tests for case when result of tail-call suspend function returning

Unit is not Unit.
 #KT-34703 Fixed
This commit is contained in:
Ilmir Usmanov
2019-11-01 02:30:29 +03:00
parent ca527444cb
commit 8c079706a5
5 changed files with 104 additions and 5 deletions
@@ -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"
}
@@ -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"
}