Initialize builder inference lambda anyway, even a call is inapplicable

^KT-47744 Fixed
This commit is contained in:
Victor Petukhov
2021-07-15 11:17:27 +03:00
committed by teamcityserver
parent 2b0ba6fa40
commit 357fda2efa
19 changed files with 227 additions and 1 deletions
@@ -0,0 +1,37 @@
// !LANGUAGE: -UnrestrictedBuilderInference
// !DIAGNOSTICS: -EXPERIMENTAL_IS_NOT_ENABLED -UNCHECKED_CAST
// WITH_RUNTIME
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 test() {
val x: Flow<String> = flow {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>produce<!> {
select<Unit> {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>onSend<!>("") {
}
}
}
}
}