Files
kotlin-fork/compiler/testData/codegen/box/casts/kt50577.kt
T
Pavel Kunyavskiy f2520a9cb7 [K/N] Rework is checks and as casts codegeneration
^KT-58707
^KT-59022
2023-06-05 08:56:17 +00:00

27 lines
386 B
Kotlin
Vendored

abstract class A {
abstract val x: Any
init {
castX(this)
}
}
class B : A() {
override val x: Any = "abc"
}
fun castX(a: A) {
a.x as String
}
fun box(): String {
try {
B()
} catch (e: NullPointerException) {
return "OK"
} catch (e: ClassCastException) {
return "OK" // JS
}
return "Failed: should throw NPE"
}