Files
kotlin-fork/compiler/testData/codegen/box/casts/kt50577.kt
T
2022-01-13 08:31:10 +00:00

29 lines
413 B
Kotlin
Vendored

// IGNORE_BACKEND: NATIVE
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"
}