Can't infer type with RxJava's retryWhen

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?

1 Like

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

1 Like