Support suspend functions as superinterfaces

Forbid mixing suspend and non-suspend functional supertypes.
Since JVM BE generates suspend functional types as non-suspend ones
with SuspendFunction marker interface, there is not way to distinguish
non-suspend functional type from suspend one if they are mixed.
 #KT-18707 Fixed
This commit is contained in:
Ilmir Usmanov
2021-04-26 16:16:25 +02:00
parent 37ccd82b6c
commit dc2485ae71
44 changed files with 1439 additions and 2 deletions
@@ -0,0 +1,31 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS, JS_IR, JVM
// !LANGUAGE: +SuspendFunctionAsSupertype
import kotlin.coroutines.*
var res = "FAIL"
class C: suspend () -> Unit {
override suspend fun invoke() {
res = "OK"
}
}
fun box(): String {
val o: suspend () -> Unit = object : suspend () -> Unit {
override suspend fun invoke() {
res = "OK"
}
}
o.startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
if (res != "OK") return "FAIL 1: $res"
res = "FAIL 2"
C().startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
return res
}