mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 15:54:03 +00:00
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.
33 lines
647 B
Kotlin
Vendored
33 lines
647 B
Kotlin
Vendored
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
|
|
|
// IGNORE_BACKEND: JVM, JVM_IR, JS_IR
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// SKIP_DCE_DRIVEN
|
|
|
|
fun interface Base {
|
|
fun doStuff(): String
|
|
}
|
|
|
|
fun interface I : Base
|
|
|
|
fun interface Proxy : I {
|
|
|
|
override fun doStuff(): String = doStuffInt().toString()
|
|
|
|
fun doStuffInt(): Int
|
|
}
|
|
|
|
fun runBase(b: Base) = b.doStuff()
|
|
|
|
fun runI(i: I) = i.doStuff()
|
|
|
|
fun runProxy(p: Proxy) = p.doStuff()
|
|
|
|
fun box(): String {
|
|
|
|
if (runI { "i" } != "i") return "fail1"
|
|
|
|
if (runProxy { 10 } != "10") return "fail2"
|
|
|
|
return runBase { "OK" }
|
|
} |