Throw NPE instead of TypeCastException since 1.4

#KT-22275 In Progress
This commit is contained in:
Alexander Udalov
2019-08-06 11:21:48 +02:00
parent 2baddb029c
commit e207c96336
9 changed files with 48 additions and 13 deletions
+13
View File
@@ -0,0 +1,13 @@
// !API_VERSION: LATEST
// TARGET_BACKEND: JVM
fun box(): String {
val s: String? = null
try {
s as String
return "Fail: NPE should have been thrown"
} catch (e: Throwable) {
if (e::class != NullPointerException::class) return "Fail: exception class should be NPE: ${e::class}"
return "OK"
}
}