// WITH_RUNTIME import kotlin.coroutines.* interface Flow { suspend fun collect(collector: FlowCollector) } interface FlowCollector { suspend fun emit(value: T) } suspend inline fun Flow.collect(crossinline action: suspend (value: T) -> Unit): Unit = collect(object : FlowCollector { override suspend fun emit(value: T) = action(value) }) fun builder(c: suspend () -> Unit) { c.startCoroutine(Continuation(EmptyCoroutineContext) { it.getOrThrow() }) } fun box(): String { val flow: Flow> = object : Flow> { override suspend fun collect(collector: FlowCollector>) { collector.emit(Result.success("OK")) } } var res = "FAIL" builder { flow.collect { result -> result.onSuccess { text -> res = text } } } return res }