Support loading function types

This commit is contained in:
Ilmir Usmanov
2018-07-05 21:00:38 +03:00
parent 5b7e099842
commit dbc3ddc578
3 changed files with 38 additions and 1 deletions
@@ -0,0 +1,32 @@
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
import kotlin.coroutines.experimental.*
fun builder(c: suspend () -> String): String {
var res = "FAIL"
c.startCoroutine(object : Continuation<String> {
override val context = EmptyCoroutineContext
override fun resume(value: String) {
res = value
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
return res
}
// FILE: B.kt
// LANGUAGE_VERSION: 1.3
import kotlin.coroutines.experimental.*
fun ok(continuation: Continuation<String>): Any? {
return "OK"
}
fun box(): String {
if (builder(::ok) != "OK") return "FAIL 1"
if (builder { cont: Continuation<String> -> "OK" } != "OK") return "FAIL 2"
if (builder(fun (cont: Continuation<String>): Any? = "OK") != "OK") return "FAIL 2"
return "OK"
}