Files
kotlin-fork/compiler/testData/ir/irText/expressions/smartCasts.kt
T
2020-02-28 15:29:01 +03:00

26 lines
466 B
Kotlin
Vendored

// FIR_IDENTICAL
// WITH_RUNTIME
fun expectsString(s: String) {}
fun expectsInt(i: Int) {}
fun overloaded(s: String) = s
fun overloaded(x: Any) = x
fun test1(x: Any) {
if (x !is String) return
println(x.length)
expectsString(x)
expectsInt(x.length)
expectsString(overloaded(x))
}
fun test2(x: Any): String {
if (x !is String) return ""
return overloaded(x)
}
fun test3(x: Any): String {
if (x !is String) return ""
return x
}