Fix casts of Unit value to other types

This commit is contained in:
Alexander Udalov
2015-07-04 03:10:09 +03:00
parent 62c22bf0ec
commit cb03f0df5a
7 changed files with 52 additions and 15 deletions
@@ -0,0 +1,15 @@
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"
}