Fix codegen box tests for language version 1.4

Since API version 1.4, NullPointerException is thrown for casts of null
to any type instead of TypeCastException.
This commit is contained in:
Alexander Udalov
2020-01-20 16:55:53 +01:00
parent 6a90dc2efe
commit f48bdc1fcb
17 changed files with 115 additions and 51 deletions
@@ -12,15 +12,15 @@ fun case1(): Int =
null.castTo<Int?, Int>()
fun box(): String {
failTypeCast { case1(); return "failTypeCast 9" }
failNPE { case1(); return "Fail" }
return "OK"
}
inline fun failTypeCast(s: () -> Unit) {
inline fun failNPE(s: () -> Unit) {
try {
s()
}
catch (e: TypeCastException) {
catch (e: NullPointerException) {
// OK
}
}