Fix super calls to suspend functions in abstract classes
This commit is contained in:
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
abstract class A(val v: String) {
|
||||
suspend abstract fun foo(v: String): String
|
||||
|
||||
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
|
||||
x.resume(v)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
open suspend fun suspendHere(): String = foo("O") + suspendThere(v)
|
||||
}
|
||||
|
||||
class B(v: String) : A(v) {
|
||||
override suspend fun foo(v: String): String = suspendCoroutineOrReturn { x ->
|
||||
x.resume(v)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
override suspend fun suspendHere(): String = super.suspendHere() + suspendThere("56")
|
||||
}
|
||||
|
||||
fun builder(c: suspend A.() -> Unit) {
|
||||
c.startCoroutine(B("K"), EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
builder {
|
||||
result = suspendHere()
|
||||
}
|
||||
|
||||
if (result != "OK56") return "fail 1: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user