Reputation: 11450
Is there a way to get a function reference to a generic extension function/method in Kotlin?
class C
fun <T> C.f1(t: T) = TODO()
val f1Ref1 = C::f1<T> // Compiler error
val f1Ref2 = C::f1 // Compiler error
But this is fine:
fun C.f2(i: Int) = TODO()
val f2Ref = C::f2
Upvotes: 3
Views: 208
Reputation: 9682
You must specify the type explicitly
val f1Ref1: C.(Int) -> Unit = C::f1
Upvotes: 5