Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignment.kt
T
2022-10-12 08:21:13 +00:00

20 lines
431 B
Kotlin
Vendored

class Foo<T : Any> {
fun doSmthng(arg: T) {}
var a: T? = null
}
fun <T : Any> myBuilder(block: Foo<T>.() -> Unit) : Foo<T> = Foo<T>().apply(block)
fun main(arg: Any) {
val x = 57
val value = myBuilder {
doSmthng("one ")
a = <!TYPE_MISMATCH!>57<!>
a = <!TYPE_MISMATCH!>x<!>
if (arg is String) {
a = arg
}
}
println(value.a?.count { it in 'l' .. 'q' })
}