Files
kotlin-fork/backend.native/tests/codegen/basics/unchecked_cast2.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

10 lines
194 B
Kotlin

fun main(args: Array<String>) {
try {
val x = cast<String>(Any())
println(x.length)
} catch (e: Throwable) {
println("Ok")
}
}
fun <T> cast(x: Any?) = x as T