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
Dominaezzz
03/18/2021, 5:48 PM
That's because the type is wrong. You need an instance of the interface to make that signature work.
Dominaezzz
03/18/2021, 5:49 PM
I think you can add the interface as a receiver to the function type.