IR: 'fun interface' support

This commit is contained in:
Dmitry Petrov
2020-01-20 13:36:53 +03:00
parent a55989a2a5
commit 64a405e7a0
40 changed files with 977 additions and 30 deletions
@@ -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)
}