Skip to content
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

Operators without co- or contravariance #494

Closed
akarnokd opened this issue Nov 18, 2013 · 3 comments
Closed

Operators without co- or contravariance #494

akarnokd opened this issue Nov 18, 2013 · 3 comments

Comments

@akarnokd
Copy link
Member

I'm looking at the operator definition and found a bunch of places where the "lambda" functions do not have wildcard bounds specified, e.g.,

reduce(Func2[T, T, T])
max(Comparator[T])

etc.
Is there a particular reason these are not:

reduce(Func2[? super T, ? super T, ? extends T])
max(Comparator[? super T])

?

@samuelgruetter
Copy link
Contributor

reduce:

That's a long story, see #369 , #360 , and #336 (comment) .
In short:

  • It's considered unnecessary (or not necessary enough to complicate the signature)
  • Note, though, that the signature of reduce is not entirely correct, because the covariant type parameter T appears in a contravariant position, so you can't use reduce on an Observable<? extends XXX> , but only on an Observable<XXX> . To fix this, one would need lower bounds for type parameters, but Java doesn't support this.

min/max:

IMHO it would be a good idea to add wildcards, what do others think?

@zsxwing
Copy link
Member

zsxwing commented Nov 19, 2013

For min/max, I agree with you. I'll fix it.

@zsxwing
Copy link
Member

zsxwing commented Nov 21, 2013

It seems we can close this issue now.

jihoonson pushed a commit to jihoonson/RxJava that referenced this issue Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants