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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user