Files
kotlin-fork/js/js.translator/testData/box/native/castToNativeInterface.kt
T
2017-01-27 01:29:15 +03:00

20 lines
365 B
Kotlin
Vendored

// FILE: castToNativeInterface.kt
external interface I {
fun foo(): String
}
external class A(x: String) : I {
override fun foo(): String = definedExternally
}
fun createObject(): Any = A("OK")
fun box() = (createObject() as I).foo()
// FILE: castToNativeInterface.js
function A(x) {
this.x = x;
}
A.prototype.foo = function() {
return this.x;
}