Files
kotlin-fork/js/js.translator/testData/box/native/passMemberOrExtToNative.kt
T
Nikolay Lunyak a20e29e8b7 [FIR JS] Implement FirJsExternalChecker
The JsAllowValueClassesInExternals feature is enabled explicitly,
because otherwise it's enabled
implicitly depending on the backend. See:
org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt:90

A property may have a fake source return kind, while its accessor
has a real source kind. In this case we can't "just copy"
the property return type down to the accessor.
2023-01-09 08:57:11 +00:00

45 lines
1.2 KiB
Kotlin
Vendored

// IGNORE_BACKEND_K1: JS_IR
// IGNORE_BACKEND_K2: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// TODO: Unmute when extension functions are supported in external declarations.
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: WASM
package foo
open class A(val v: String) {
open fun m(i:Int, s:String): String = "A.m ${this.v} $i $s"
}
class B(v: String): A(v) {
override fun m(i:Int, s:String): String = "B.m ${this.v} $i $s"
}
external fun bar(a: A, extLambda: A.(Int, String) -> String): String = definedExternally
fun A.topLevelExt(i:Int, s:String): String = "A::topLevelExt ${this.v} $i $s"
fun box(): String {
val a = A("test")
var r = bar(a) { i, s -> "${this.v} $i $s"}
if (r != "test 4 boo") return r
fun A.LocalExt(i:Int, s:String): String = "A::LocalExt ${this.v} $i $s"
r = bar(a, fun A.(i, s) = (A::topLevelExt)(this, i, s))
if (r != "A::topLevelExt test 4 boo") return r
r = bar(a, fun A.(i, s) = (A::LocalExt)(this, i, s))
if (r != "A::LocalExt test 4 boo") return r
r = bar(a, fun A.(i, s) = (A::m)(this, i, s))
if (r != "A.m test 4 boo") return r
val b = B("test")
r = bar(b, fun A.(i, s) = (A::m)(this, i, s))
if (r != "B.m test 4 boo") return r
return "OK"
}