IR: 'fun interface' support
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun interface Fn<T, R> {
|
||||
fun run(s: String, i: Int, t: T): R
|
||||
}
|
||||
|
||||
class J {
|
||||
fun runConversion(f1: Fn<String, Int>, f2: Fn<Int, String>): Int {
|
||||
return f1.run("Bar", 1, f2.run("Foo", 42, 239))
|
||||
}
|
||||
}
|
||||
|
||||
val fsi = object : Fn<String, Int> {
|
||||
override fun run(s: String, i: Int, t: String): Int = 1
|
||||
}
|
||||
|
||||
val fis = object : Fn<Int, String> {
|
||||
override fun run(s: String, i: Int, t: Int): String = ""
|
||||
}
|
||||
|
||||
fun test(j: J) {
|
||||
j.runConversion(fsi) { s, i, ti -> ""}
|
||||
j.runConversion({ s, i, ts -> 1 }, fis)
|
||||
}
|
||||
Reference in New Issue
Block a user