Files
kotlin-fork/js/js.translator/testData/box/native/castToNativeClassChecked.kt
T
Zalim Bashorov b02279de14 [Wasm] Run wasm test using all available VMs: V8 & SpiderMonkey for now
Also, add a new directive, `WASM_FAILS_IN`, to specify VMs where a test is expected to fail for now.

#KT-56166 Fixed
2023-01-27 17:57:50 +01:00

31 lines
568 B
Kotlin
Vendored

// WASM_FAILS_IN: SM
// 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;
}