Kotlin unable to infer type when using method reference in Flowable

Viewed 500

I have this code in Java:

Flowable.just(1,2,3)
        .flatMap(Flowable::just);

and this code in Kotlin:

Flowable.just(1,2,3)
        .flatMap(Flowable::just)

While Java code compiles fine, Kotlin compiler says: "Error:(47, 30) Kotlin: One type argument expected for class Flowable : Publisher defined in io.reactivex"

However this compiles fine:

Flowable.just(1,2,3)
        .flatMap { Flowable.just(it) }

What am I doing wrong or how come Kotlin can't infer the type of Flowable automatically?

1 Answers
Related