Substitute lambda's receiver type during completion including the builder inference stub variables substitution

^KT-42175 Fixed
This commit is contained in:
Victor Petukhov
2020-12-25 17:27:06 +03:00
parent 672859d447
commit 37473ad640
10 changed files with 84 additions and 3 deletions
@@ -0,0 +1,22 @@
// WITH_RUNTIME
// DONT_TARGET_EXACT_BACKEND: WASM
import kotlin.experimental.ExperimentalTypeInference
operator fun <T> SequenceScope<String>.plusAssign(x: SequenceScope<T>) {}
@OptIn(ExperimentalTypeInference::class)
fun <T> mySequence(@BuilderInference block: suspend SequenceScope<T>.() -> Unit): Sequence<T> = Sequence { iterator(block) }
fun main() {
val y: Sequence<String> = mySequence {
yield("result")
this += this
}
}
fun box(): String {
main()
return "OK"
}