blob: 10171dd33fe50ad03c1ad9c19301f6cda07e5382 [file] [log] [blame]
// WITH_RUNTIME
import kotlin.test.assertEquals
inline fun<reified T> safecast(x: Any?): T? {
return x as? T
}
fun box(): String {
val x = safecast<String>("abc")
assertEquals("abc", x)
val y = safecast<Int>(1)
assertEquals(1, y)
val z = safecast<Int>("abc")
assertEquals(null, z)
return "OK"
}