// COMMON_COROUTINES_TEST // WITH_RUNTIME // WITH_COROUTINES // There should be no $foo$$inlined$map$1$1 class interface FlowCollector { suspend fun emit(value: T) } interface Flow { suspend fun collect(collector: FlowCollector) } public inline fun flow(crossinline block: suspend FlowCollector.() -> Unit) = object : Flow { override suspend fun collect(collector: FlowCollector) = collector.block() } suspend inline fun Flow.collect(crossinline action: suspend (T) -> Unit): Unit = collect(object : FlowCollector { override suspend fun emit(value: T) = action(value) }) public inline fun Flow.transform(crossinline transformer: suspend FlowCollector.(value: T) -> Unit): Flow { return flow { return@flow collect { value -> return@collect transformer(value) } } } public inline fun Flow.map(crossinline transformer: suspend (value: T) -> R): Flow = transform { value -> return@transform emit(transformer(value)) } suspend fun foo() { flow { emit(1) }.map { it + 1 } .collect { } }