Move tests for builder inference into the corresponding directory
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
// Issue: KT-36371
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
class Foo(val string: String? = null)
|
||||
|
||||
class Builder<T> {
|
||||
private var resolver: ((Foo) -> T)? = null
|
||||
fun build() = resolver!!
|
||||
|
||||
fun resolve(resolver: (Foo) -> T) {
|
||||
this.resolver = resolver
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
fun <T> build(@BuilderInference configure: Builder<T>.() -> Unit) =
|
||||
Builder<T>().apply(configure).build()
|
||||
|
||||
fun box(): String {
|
||||
val resolver = build {
|
||||
resolve { it.string }
|
||||
}
|
||||
|
||||
resolver(Foo())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user