On Mon, 6 Nov 2023 11:08:08 GMT, Viktor Klang <vkl...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/stream/Gatherer.java line 308:
>> 
>>> 306:      */
>>> 307:     static <T, R> Gatherer<T, Void, R> ofSequential(
>>> 308:             Integrator<Void, T, R> integrator) {
>> 
>> Probably PECS signature `? super T, ? extends R` could be useful here?
>
> I've thought about that, and since we don't use that for the other parameters 
> (like `initializer`) I don't think it helps changing it here. And the reason 
> this has little effect is that the code calling the factory typically 
> controls the components/parameters/return type.

It's still possible to have a situation where PECS signature could be useful, 
and I don't see any downsides. A user may want to reuse the same static 
integrator instead of creating several identical lambdas just because the 
target type is more specific. Sometimes, people complain later, and you'll have 
to fix this. For example, see that `Stream.generate()` [was fixed 
separately](https://bugs.openjdk.org/browse/JDK-8132097). So why not doing this 
from the very beginning?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1386688266

Reply via email to