Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/builderInference/constraints/violating.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

34 lines
792 B
Kotlin
Vendored

// !LANGUAGE: +UnrestrictedBuilderInference
// WITH_STDLIB
interface A {
fun foo(): MutableList<String>
}
@ExperimentalStdlibApi
fun main() {
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
object : A {
override fun foo(): MutableList<String> = this@buildList
}
}
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
val x: String = get(0)
}
buildList {
add(<!TYPE_MISMATCH!>"3"<!>)
val x: MutableList<Int> = this@buildList
}
buildList {
val y: CharSequence = ""
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>y<!>)
val x: MutableList<String> = this@buildList
}
buildList {
add(<!TYPE_MISMATCH!>""<!>)
val x: StringBuilder = get(0)
}
}