Hey guys, I have a Kotlin class with some reified and equivalent normal functions:
// Java fun
fun <T:E> registerEvent(cls:Class<T>, consumer: Consumer<T>) : Disposable {
return this.listen(cls)
.subscribe(consumer)
}
// Kotlin fun (calls the java one)
inline fun <reified T:E> registerEvent(consumer: Consumer<T>): Disposable {
return registerEvent(T::class.java, consumer)
}
In java I have no problem calling
registerEvernt(SomeClass.class, this::consumerMethod)
, but in Kotlin, when I try to do a method reference for the consumer, the compiler gives me an error and says it returns a
KFunction1<SomeClass, Unit>
and the required parameter is
Consumer<SomeClass>
. Is there any way I can make the functions behave the same, or is the
inline
or something else making it impossible?