Files
kotlin-fork/backend.native/tests/codegen/basics/unchecked_cast1.kt
T
Svyatoslav Scherbina 65444ec690 backend: improve type operators support:
* add initial support for casts with generics;
* optimize out the casts to subtypes

Also add tests unchecked_cast{1,2}, the latter is disabled.
2017-01-20 20:02:50 +07:00

16 lines
260 B
Kotlin

fun main(args: Array<String>) {
foo<String>("17")
bar<String>("17")
foo<String>(42)
bar<String>(42)
}
fun <T> foo(x: Any?) {
val y = x as T
println(y.toString())
}
fun <T> bar(x: Any?) {
val y = x as? T
println(y.toString())
}