39 lines
662 B
Kotlin
Vendored
39 lines
662 B
Kotlin
Vendored
// FIR_IDENTICAL
|
|
// ALLOW_KOTLIN_PACKAGE
|
|
// !LANGUAGE: +UnrestrictedBuilderInference
|
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
// FILE: annotation.kt
|
|
|
|
package kotlin
|
|
|
|
annotation class BuilderInference
|
|
|
|
// FILE: test.kt
|
|
|
|
class Builder<T> {
|
|
fun add(t: T) {}
|
|
}
|
|
|
|
fun <S> build(g: Builder<S>.() -> Unit): List<S> = TODO()
|
|
fun <S> wrongBuild(g: Builder<S>.() -> Unit): List<S> = TODO()
|
|
|
|
fun <S> Builder<S>.extensionAdd(s: S) {}
|
|
|
|
fun <S> Builder<S>.safeExtensionAdd(s: S) {}
|
|
|
|
val member = build {
|
|
add(42)
|
|
}
|
|
|
|
val memberWithoutAnn = wrongBuild {
|
|
add(42)
|
|
}
|
|
|
|
val extension = build {
|
|
extensionAdd("foo")
|
|
}
|
|
|
|
val safeExtension = build {
|
|
safeExtensionAdd("foo")
|
|
}
|