Fix super calls to suspend functions in abstract classes

This commit is contained in:
Denis Zharkov
2017-05-26 17:34:58 +03:00
parent 26ef954507
commit 2c98bd053a
8 changed files with 69 additions and 6 deletions
@@ -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"
}