8132097: Stream.generate should use a covariant Supplier as parameter
Reviewed-by: forax, martin
This commit is contained in:
parent
3d0c012270
commit
4bcf62b9d1
@ -1327,7 +1327,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
|
||||
* @param s the {@code Supplier} of generated elements
|
||||
* @return a new infinite sequential unordered {@code Stream}
|
||||
*/
|
||||
public static<T> Stream<T> generate(Supplier<T> s) {
|
||||
public static<T> Stream<T> generate(Supplier<? extends T> s) {
|
||||
Objects.requireNonNull(s);
|
||||
return StreamSupport.stream(
|
||||
new StreamSpliterators.InfiniteSupplyingSpliterator.OfRef<>(Long.MAX_VALUE, s), false);
|
||||
|
@ -1346,9 +1346,9 @@ class StreamSpliterators {
|
||||
}
|
||||
|
||||
static final class OfRef<T> extends InfiniteSupplyingSpliterator<T> {
|
||||
final Supplier<T> s;
|
||||
final Supplier<? extends T> s;
|
||||
|
||||
OfRef(long size, Supplier<T> s) {
|
||||
OfRef(long size, Supplier<? extends T> s) {
|
||||
super(size);
|
||||
this.s = s;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user