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

25 lines
615 B
Kotlin
Vendored

// DONT_TARGET_EXACT_BACKEND: WASM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference
class Foo<T> {
fun add(x: T) {}
}
@OptIn(ExperimentalTypeInference::class)
fun <K1> myBuilder1(@BuilderInference builder: Foo<K1>.() -> Foo<K1>): Foo<K1> = Foo<K1>().apply { builder() }
@OptIn(ExperimentalTypeInference::class)
fun <K2> myBuilder2(@BuilderInference builder: Foo<K2>.() -> Unit): Foo<K2> = Foo<K2>().apply(builder)
fun box(): String {
val result1 = myBuilder1 {
add(null)
myBuilder2 {
add("")
}
}
return "OK"
}