RFR(s): 8152617 add missing wildcards to Optional or() and flatMap()
spliterator at gmail.com
Sat Oct 8 09:04:59 UTC 2016
> Turns out that Rémi's example exposes the difference between the wildcard
> approach and the type-parameter approach. Returning to the example,
> Optional<Integer> oi = Optional.empty();
> Function<Number, Optional<StringBuilder>> fm = n -> Optional.empty();
> Optional<CharSequence> ocs = oi.flatMap(fm);
> If the flatMapper function itself has a wildcard type, for example,
> Function<Number, Optional<? extends CharSequence>> fm = n ->
> then this will still work with the wildcard approach but fail with the
> type-parameter approach. As Rémi also pointed out, a wildcarded type can
> result from the capture of a type with a wildcarded type parameter.
> Based on this, I believe the nested wildcard approach to be the correct one.
Yes, this argument is unchallengeable.
I'm convinced now - though not happy.
More information about the core-libs-dev