-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
@OptIn(InternalCoroutinesApi::class)
@Suppress("DEPRECATION_ERROR", "INVISIBLE_MEMBER")
fun main() {
runBlocking {
launch(SupervisorJob()) {
// failed child cancels parent,
// which turns out not to be a supervisor,
// but a regular StandaloneCoroutine
async {
throw RuntimeException("child failure")
}
// one can verify it
val thisJob = coroutineContext.job
println(thisJob) // StandaloneCoroutine
println((thisJob as JobSupport).parentHandle?.parent) // SupervisorJobImpl
}.join()
}
}
Basically, this is equivalent to
CoroutineScope(coroutineContext + SupervisorJob()).launch {
...
}
which, at least, is obvious.