mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-12 00:21:32 +00:00
16 lines
340 B
Kotlin
Vendored
16 lines
340 B
Kotlin
Vendored
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.getMessage()}"
|
|
}
|
|
|
|
return "Fail: no exception was thrown"
|
|
}
|