Files
kotlin-fork/compiler/testData/codegen/box/inference/builderInference.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

32 lines
710 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
// ISSUE: KT-33545
import kotlin.experimental.ExperimentalTypeInference
interface Flow<out T> {
suspend fun collect(collector: FlowCollector<T>)
}
interface FlowCollector<in T> {
suspend fun emit(value: T)
}
inline fun <T> Flow<T>.collect(crossinline action: suspend (value: T) -> Unit): Unit {}
abstract class LiveData<T>
interface LiveDataScope<T> {
suspend fun emit(value: T)
}
@OptIn(ExperimentalTypeInference::class)
fun <T> liveData(@BuilderInference block: suspend LiveDataScope<T>.() -> Unit): LiveData<T> = null!!
fun <Value> Flow<Value>.asLiveData() = liveData {
collect(this::emit)
// collect { emit(it) }
}
fun box(): String = "OK"