Can't infer type with RxJava's retryWhen


#1

I’ve just learnt RxJava with Kotlin.
Today I found a problem.
Simplify the code is:

Observable.range(1, 10)
            .retryWhen { attempts ->
                attempts.flatMap { error ->
                    Observable.error(error)
                }
            }

The error value-parameter here is Any? in Kotlin.

But in Java:

Observable.range(1, 10)
	.retryWhen(attempts ->
		attempts.flatMap(error ->
			Observable.error(error)
		)
	);

The error value-parameter is ? extends Throwable here in Java.

Is it a bug?


#2

Yes, seems that it’s a known bug in type-inference: https://youtrack.jetbrains.com/issue/KT-12238