Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignment_noReport.kt
T
2022-10-26 09:21:48 +00:00

22 lines
454 B
Kotlin
Vendored

// !LANGUAGE: +NoBuilderInferenceWithoutAnnotationRestriction
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 = 57
a = x
if (arg is String) {
a = arg
}
}
println(value.a?.count { it in 'l' .. 'q' })
}