is it somehow possible to deal with the following ...
# announcements
r
is it somehow possible to deal with the following problem.
Copy code
interface I1{ fun foo(f: (Int) -> Int) }
interface I2{ fun foo(f: (String) -> String) }
class A: I1, I2{
  override fun foo(f: (Int) -> Int){}
  override fun foo(f: (String)-> String){} //same JVM signature
}
p
Seems it only works for global functions
h
This has bit me a number of times, AFAIK there's no way around it. Be awesome if
@JvmName
could be used as a work around (I havent tried it). We need a
@Mangle
annotation or something that will mangle it for us on the Java side when we don't care about being callable from the Java side of things.
👍 1
c
This works for me:
Copy code
interface I1 {
	fun foo(l: (Int) -> Int): Int
}

interface I2 {
	fun foo(l: (String) -> String): String
}

class A : I1, I2 {
	override fun foo(l: (Int) -> Int): Int = l(1)
	override fun foo(l: (String) -> String): String = l("a")
}

fun test() {
	println(A().foo { p: Int -> p * 2 })
	println(A().foo { p: String -> p + p })
}
I guess problem is only there if the return type is the same.
r
Ah sorry, return type should have been the same