2015-11-01 1:12 GMT+01:00 Michael Nascimento <mist...@gmail.com>: > Hi Vitaly, > > Exactly, I was just trying to point out the method signature seems broken > anyway. >
Rethinking it, I believe you are right. public <R extends T> Optional<T> or(Supplier<Optional<R>> supplier) would be more general and still be sound type-wise. There's a similar issue for Stream generate / iterate in the bugtracker https://bugs.openjdk.java.net/browse/JDK-8132097 Thanks, Stefan > On 31 Oct 2015 11:59, "Vitaly Davidovich" <vita...@gmail.com> wrote: >> >> This would require Supplier<Optional<? extends T>>, not Supplier<? extends >> Optional<T>>. >> >> sent from my phone >> >> On Oct 31, 2015 2:49 PM, "Michael Nascimento" <mist...@gmail.com> wrote: >>> >>> If this instance is an Optional<CharSequence> , passing an >>> Optional<StringBuilder> will fail to compile. >>> >>> Regards, >>> Michael