Files
kotlin-fork/js/js.translator/testData/box/native/castToNativeClassChecked.kt
T
2018-09-12 09:49:25 +03:00

30 lines
547 B
Kotlin
Vendored

// EXPECTED_REACHABLE_NODES: 1283
// FILE: castToNativeClassChecked.kt
external abstract class S() {
abstract fun foo(): String
}
external class A(x: String) {
fun foo(): String = definedExternally
}
fun createObject(): Any = A("fail: CCE not thrown")
fun box(): String {
try {
return (createObject() as S).foo()
}
catch (e: ClassCastException) {
return "OK"
}
}
// FILE: castToNativeClassChecked.js
function S() {
}
function A(x) {
this.x = x;
}
A.prototype.foo = function() {
return this.x;
}