how do i get a method reference to an overloaded i...
# codereview
c
how do i get a method reference to an overloaded interface function?
Copy code
fun method() {}
fun method(number: Int, name: String) {}

// this works
val m: ()->Unit = ::method
val m2: (Int, String)->Unit = ::method


interface IImpl {
    fun method()
    fun method(number: Int, name: String)
}
// this does not work
val m: ()->Unit = IImpl::method
val m2: (Int, String)->Unit = IImpl::method
🤔 1
d
That's because the type is wrong. You need an instance of the interface to make that signature work.
I think you can add the interface as a receiver to the function type.