Files
kotlin-fork/compiler/testData/ir/irText/expressions/smartCasts.kt.txt
T
Dmitriy Novozhilov b454fcc1e0 [FIR] Save IR dumps to .ir.txt files instead of .txt in tests
This is needed to avoid clashes between different dumps from different
  handlers
2021-10-12 17:26:36 +03:00

38 lines
634 B
Plaintext
Vendored

fun expectsString(s: String) {
}
fun expectsInt(i: Int) {
}
fun overloaded(s: String): String {
return s
}
fun overloaded(x: Any): Any {
return x
}
fun test1(x: Any) {
when {
x !is String -> return Unit
}
println(message = x /*as String */.<get-length>())
expectsString(s = x /*as String */)
expectsInt(i = x /*as String */.<get-length>())
expectsString(s = overloaded(s = x /*as String */))
}
fun test2(x: Any): String {
when {
x !is String -> return ""
}
return overloaded(s = x /*as String */)
}
fun test3(x: Any): String {
when {
x !is String -> return ""
}
return x /*as String */
}