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,20 @@
|
||||
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
||||
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// SKIP_DCE_DRIVEN
|
||||
|
||||
// This test should check argument coercion between the SAM and the lambda.
|
||||
// For now it checks that Char is boxed in JS
|
||||
|
||||
fun interface CharToAny {
|
||||
fun invoke(c: Char): Any
|
||||
}
|
||||
|
||||
fun foo(c: CharToAny): Any = c.invoke('O')
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (foo { it } !is Char) return "fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user