Files
kotlin/compiler/testData/codegen/box/casts/unitAsInt.kt
2018-12-21 16:09:05 +01:00

20 lines
376 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
fun foo() {}
fun box(): String {
try {
foo() as Int?
}
catch (e: ClassCastException) {
return "OK"
}
catch (e: Throwable) {
return "Fail: ClassCastException should have been thrown, but was instead ${e.javaClass.getName()}: ${e.message}"
}
return "Fail: no exception was thrown"
}