Files
kotlin-fork/compiler/testData/codegen/box/inference/builderInference/kt47744.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

38 lines
932 B
Kotlin
Vendored

// !LANGUAGE: +UnrestrictedBuilderInference
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference
@OptIn(ExperimentalTypeInference::class)
fun <T> flow(@BuilderInference block: suspend FlowCollector<T>.() -> Unit) = Flow<T>()
@OptIn(ExperimentalTypeInference::class)
fun <E> produce(@BuilderInference block: suspend SendChannel<E>.() -> Unit) {}
interface SendChannel<in E> {
val onSend: SelectClause2<E, SendChannel<E>>
}
interface SelectClause2<in P, out Q>
class Flow<out T>
interface FlowCollector<in T>
interface SelectBuilder<in R> {
operator fun <P, Q> SelectClause2<P, Q>.invoke(param: P, block: suspend (Q) -> R)
}
inline fun <R> select(crossinline builder: SelectBuilder<R>.() -> Unit) = Unit as R
fun box(): String {
val x: Flow<String> = flow {
produce {
select<Unit> {
onSend("") {
}
}
}
}
return "OK"
}