Added phase RETURNS_INSERTION
Moved explicit insertion of return statement from code generator to a lowering
This commit is contained in:
@@ -943,6 +943,18 @@ task coroutines_simple(type: RunKonanTest) {
|
||||
source = "codegen/coroutines/simple.kt"
|
||||
}
|
||||
|
||||
task coroutines_degenerate1(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // llvm: 'WebAssembly hasn't implemented computed gotos'
|
||||
goldValue = "s1\n"
|
||||
source = "codegen/coroutines/degenerate1.kt"
|
||||
}
|
||||
|
||||
task coroutines_degenerate2(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // llvm: 'WebAssembly hasn't implemented computed gotos'
|
||||
goldValue = "s2\ns1\n"
|
||||
source = "codegen/coroutines/degenerate2.kt"
|
||||
}
|
||||
|
||||
task coroutines_withReceiver(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // llvm: 'WebAssembly hasn't implemented computed gotos'
|
||||
goldValue = "42\n"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resume(value: Any?) {}
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
}
|
||||
|
||||
suspend fun s1() {
|
||||
println("s1")
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
builder {
|
||||
s1()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resume(value: Any?) {}
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
}
|
||||
|
||||
suspend fun s1(): Unit = suspendCoroutineOrReturn { x ->
|
||||
println("s1")
|
||||
x.resume(Unit)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
suspend fun s2() {
|
||||
println("s2")
|
||||
s1()
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
builder {
|
||||
s2()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user