RFR(s): 8152617 add missing wildcards to Optional or() and flatMap()

Paul Sandoz paul.sandoz at oracle.com
Fri Oct 7 19:56:27 UTC 2016


> On 7 Oct 2016, at 12:22, Stuart Marks <stuart.marks at oracle.com> wrote:
> 
> 
> 
> On 10/7/16 11:23 AM, Paul Sandoz wrote:
>>>   flatMap(Function<? super T, ? extends Optional<? extends U>> mapper)
>> 
>> Optional is final so why do you need to express “? extends Optional” ?
> 
> The short answer is, it doesn't work if you don't have it. :-)
> 

I thought as much :-)


> The theoretical answer is that in this context, "? extends P<Q>" means "some subtype of P<Q>" and not necessarily just a subclass of P.
> 

Doh!, yes, that makes sense. Thanks for the detailed explanation. Fix looks good.

Paul.


More information about the core-libs-dev mailing list