-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RxJava 2.0.5 breaks transformers in Kotlin #5026
Comments
Can't you specify the type argument when using compose? .compose(Transformers.<T>takeWhileViewAttachedObservable(presenter)) Otherwise, if you read the discussion the former non-variant version was problematic under Java 8. |
That doesn't work in Kotlin (at least I didn't find a way). And if I try to do this in the Java 8 code after applying my change to the method signature, then that doesn't work either. |
My bad, I missed the correct syntax, then it works in Kotlin .compose(Transformers.takeWhileViewAttachedObservable<String>(presenter)) So the situation got better for Java, but worse for Kotlin. |
It is due to how type inference and type-variance is implemented in Java and Kotlin. I don't know if they can interoperate on this one but seems explicit typing still allows fixing the ambiguities. However, since you are in Kotlin, you can define an extension method with the old syntax and avoid specifying type arguments manually. |
Right, that's a great idea. Thanks! |
This is very likely related to #4972.
My method signature looks like this
This is a generic transformer which we reuse in our project. In Java 7 it was possible to specify the type, so that subscribers below knew the correct type
Even better in Java 8 and Kotlin we could avoid the type declaration.
After updating to
2.0.5
our code in Kotlin broke. Subscribers below thecompose()
method, didn't see the correct type anymore, but onlyAny
(equivalent toObject
).I changed the method signature from our reusable transformer to
That fixed the problem in Kotlin, but now Java 8 code is complaining and only sees
Object
and not the correct event type anymore.I don't know why that's the case or how the best solution looks like. I'm wondering if this change was necessary.
The text was updated successfully, but these errors were encountered: