And `as Any?` only works because there is such an ...
# announcements
d
And
as Any?
only works because there is such an overload for
println
. Following example does not work:
Copy code
fun main(args: Array<String>) {
    var test = Test(null)
    if (test.foo != null) {
        myFun(test.foo as Int?) // "Unnecessary cast"
        myFun(test.foo) // Tries to smart-cast and fails, compile error
    }
}

fun myFun(a: Int) = Unit
fun myFun(a: Int?) = Unit