// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // WITH_STDLIB // WITH_COROUTINES import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* interface CoroutineScope object MyCoroutineScope : CoroutineScope interface Flow { suspend fun collect(): String } inline fun flow(crossinline block: suspend () -> String) = object : Flow { override suspend fun collect(): String = block() } fun CoroutineScope.launch(c: suspend () -> String): String { var result: String = "fail" c.startCoroutine(handleResultContinuation { value -> result = value }) return result } context(CoroutineScope) fun Flow.launchFlow() = launch { collect() } fun simpleFlow(): Flow = flow { "OK" } fun box(): String { return with(MyCoroutineScope) { simpleFlow().launchFlow() } }