JS: support SAM conversion
The SAM adapter is generate on declaration site. This is different from the JVM approach. `external fun interface` is banned for now. Reusing interface declaration for the adapter is a hack which reduces code size and makes importing/exporting the adapter effortless.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
||||
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// SKIP_DCE_DRIVEN
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: m1.kt
|
||||
|
||||
fun interface I {
|
||||
fun f(): String
|
||||
}
|
||||
|
||||
fun rn(i: I) = i.f()
|
||||
|
||||
inline fun rnInline(i: I) = i.f()
|
||||
|
||||
// MODULE: m2(m1)
|
||||
// FILE: m2.kt
|
||||
|
||||
fun rn2(f: () -> String) = rn(f)
|
||||
|
||||
inline fun rn2Inline(noinline f: () -> String) = rnInline(f)
|
||||
|
||||
// MODULE: main(m2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (rn2Inline { "inline" } != "inline") return "fail"
|
||||
|
||||
return rn2 { "OK" }
|
||||
}
|
||||
Reference in New Issue
Block a user