[K/N] Use suspend function desugaring lowerings.
This commit is contained in:
committed by
Space Team
parent
8886e1b8b4
commit
817dba8564
+33
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
package codegen.function.unreachable_statement_after_return
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun test1(): Any? {
|
||||
return 1
|
||||
@@ -25,10 +26,42 @@ fun test4(): Int {
|
||||
42
|
||||
}
|
||||
|
||||
suspend fun test5(): Any? {
|
||||
return 5
|
||||
42
|
||||
}
|
||||
|
||||
suspend fun test6(): Int? {
|
||||
return 6
|
||||
42
|
||||
}
|
||||
|
||||
suspend fun test7(): Any {
|
||||
return 7
|
||||
42
|
||||
}
|
||||
|
||||
suspend fun test8(): Int {
|
||||
return 8
|
||||
42
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun <T> (suspend () -> T).runCoroutine() : T {
|
||||
var result : Any? = null
|
||||
startCoroutine(Continuation(EmptyCoroutineContext) { result = it.getOrThrow() })
|
||||
return result as T
|
||||
}
|
||||
|
||||
fun main() {
|
||||
println(test1())
|
||||
println(test2())
|
||||
println(test3())
|
||||
println(test4())
|
||||
|
||||
println(::test5.runCoroutine())
|
||||
println(::test6.runCoroutine())
|
||||
println(::test7.runCoroutine())
|
||||
println(::test8.runCoroutine())
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -2,3 +2,7 @@
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
|
||||
Reference in New Issue
Block a user