RFR: 8015315: Stream.concat methods
forax at univ-mlv.fr
Mon Jul 1 13:19:49 UTC 2013
On 07/01/2013 01:36 PM, Peter Levart wrote:
> On 07/01/2013 11:52 AM, Remi Forax wrote:
>> On 06/29/2013 02:58 AM, Henry Jen wrote:
>>> Please review the webrev that add concat static method to Stream and
>>> primitive Streams.
>> Hi Henry,
>> I find the the cast to Spliterator<T> in Streams.concat() dubious,
>> I can not see how it can be correct, could you explain why this cast
>> is Ok.
> I think that if we want to concat say Stream<Integer> with
> Stream<Long>, producing Stream<Number>, there would have to be an
> unsafe cast somewhere. Since Stream<T> API apears to be covariant
> (like for example Iterator<T>), casting Stream<? extends T> to
> Stream<T> seems to be safe.
if Stream is covariant, it should be possible to create a Stream<T> from
a Spliterator<? extends T>,
so there is no need of such unsafe cast.
> Regards, Peter
More information about the core-libs-dev