8132097: Stream.generate should use a covariant Supplier as parameter

Reviewed-by: forax, martin
This commit is contained in:
Paul Sandoz 2016-11-16 14:26:12 -08:00
parent 3d0c012270
commit 4bcf62b9d1
2 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}