Change generic comment syntax to real generic syntax.
R=nweiz@google.com
Review-Url: https://codereview.chromium.org//2660333005 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5685503..be8377c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 1.13.0
+<<<<<<< ours
* Add `collectBytes` and `collectBytesCancelable` functions which collects
list-of-byte events into a single byte list.
@@ -8,6 +9,11 @@
* `StreamQueue.withTransaction()` now properly returns whether or not the
transaction was committed.
+=======
+* Add a `collectBytes` function which collects list-of-byte events into
+ a single byte list.
+* Switched to using generic method syntax.
+>>>>>>> theirs
## 1.12.0
diff --git a/lib/src/delegate/event_sink.dart b/lib/src/delegate/event_sink.dart
index 14501b2..54c3e52 100644
--- a/lib/src/delegate/event_sink.dart
+++ b/lib/src/delegate/event_sink.dart
@@ -22,8 +22,8 @@
/// instance of `EventSink`, not `EventSink<T>`. This means that calls to
/// [add] may throw a [CastError] if the argument type doesn't match the
/// reified type of [sink].
- static EventSink/*<T>*/ typed/*<T>*/(EventSink sink) =>
- sink is EventSink/*<T>*/ ? sink : new DelegatingEventSink._(sink);
+ static EventSink<T> typed<T>(EventSink sink) =>
+ sink is EventSink<T> ? sink : new DelegatingEventSink._(sink);
void add(T data) {
_sink.add(data);
diff --git a/lib/src/delegate/future.dart b/lib/src/delegate/future.dart
index e30d41d..4704343 100644
--- a/lib/src/delegate/future.dart
+++ b/lib/src/delegate/future.dart
@@ -19,15 +19,15 @@
/// This soundly converts a [Future] to a `Future<T>`, regardless of its
/// original generic type, by asserting that its value is an instance of `T`
/// whenever it's provided. If it's not, the future throws a [CastError].
- static Future/*<T>*/ typed/*<T>*/(Future future) =>
- future is Future/*<T>*/ ? future : new TypeSafeFuture/*<T>*/(future);
+ static Future<T> typed<T>(Future future) =>
+ future is Future<T> ? future : new TypeSafeFuture<T>(future);
Stream<T> asStream() => _future.asStream();
Future<T> catchError(Function onError, {bool test(Object error)}) =>
_future.catchError(onError, test: test);
- Future/*<S>*/ then/*<S>*/(dynamic onValue(T value), {Function onError}) =>
+ Future<S> then<S>(dynamic onValue(T value), {Function onError}) =>
_future.then(onValue, onError: onError);
Future<T> whenComplete(action()) => _future.whenComplete(action);
diff --git a/lib/src/delegate/sink.dart b/lib/src/delegate/sink.dart
index 326c15b..7c68a0f 100644
--- a/lib/src/delegate/sink.dart
+++ b/lib/src/delegate/sink.dart
@@ -20,8 +20,8 @@
/// instance of `Sink`, not `Sink<T>`. This means that calls to [add] may
/// throw a [CastError] if the argument type doesn't match the reified type of
/// [sink].
- static Sink/*<T>*/ typed/*<T>*/(Sink sink) =>
- sink is Sink/*<T>*/ ? sink : new DelegatingSink._(sink);
+ static Sink<T> typed<T>(Sink sink) =>
+ sink is Sink<T> ? sink : new DelegatingSink._(sink);
void add(T data) {
_sink.add(data);
diff --git a/lib/src/delegate/stream.dart b/lib/src/delegate/stream.dart
index 7562218..d08b4ab 100644
--- a/lib/src/delegate/stream.dart
+++ b/lib/src/delegate/stream.dart
@@ -23,6 +23,6 @@
/// original generic type, by asserting that its events are instances of `T`
/// whenever they're provided. If they're not, the stream throws a
/// [CastError].
- static Stream/*<T>*/ typed/*<T>*/(Stream stream) =>
- stream is Stream/*<T>*/ ? stream : new TypeSafeStream/*<T>*/(stream);
+ static Stream<T> typed<T>(Stream stream) =>
+ stream is Stream<T> ? stream : new TypeSafeStream<T>(stream);
}
diff --git a/lib/src/delegate/stream_consumer.dart b/lib/src/delegate/stream_consumer.dart
index 4f495d0..ba83040 100644
--- a/lib/src/delegate/stream_consumer.dart
+++ b/lib/src/delegate/stream_consumer.dart
@@ -22,8 +22,8 @@
/// instance of `StreamConsumer`, not `StreamConsumer<T>`. This means that
/// calls to [addStream] may throw a [CastError] if the argument type doesn't
/// match the reified type of [consumer].
- static StreamConsumer/*<T>*/ typed/*<T>*/(StreamConsumer consumer) =>
- consumer is StreamConsumer/*<T>*/
+ static StreamConsumer<T> typed<T>(StreamConsumer consumer) =>
+ consumer is StreamConsumer<T>
? consumer
: new DelegatingStreamConsumer._(consumer);
diff --git a/lib/src/delegate/stream_sink.dart b/lib/src/delegate/stream_sink.dart
index 9b52b19..198df8a 100644
--- a/lib/src/delegate/stream_sink.dart
+++ b/lib/src/delegate/stream_sink.dart
@@ -24,8 +24,8 @@
/// of `StreamSink`, not `StreamSink<T>`. This means that calls to [add] may
/// throw a [CastError] if the argument type doesn't match the reified type of
/// [sink].
- static StreamSink/*<T>*/ typed/*<T>*/(StreamSink sink) =>
- sink is StreamSink/*<T>*/ ? sink : new DelegatingStreamSink._(sink);
+ static StreamSink<T> typed<T>(StreamSink sink) =>
+ sink is StreamSink<T> ? sink : new DelegatingStreamSink._(sink);
void add(T data) {
_sink.add(data);
diff --git a/lib/src/delegate/stream_subscription.dart b/lib/src/delegate/stream_subscription.dart
index 5fa7b01..0823412 100644
--- a/lib/src/delegate/stream_subscription.dart
+++ b/lib/src/delegate/stream_subscription.dart
@@ -23,11 +23,11 @@
/// regardless of its original generic type, by asserting that its events are
/// instances of `T` whenever they're provided. If they're not, the
/// subscription throws a [CastError].
- static StreamSubscription/*<T>*/ typed/*<T>*/(
+ static StreamSubscription<T> typed<T>(
StreamSubscription subscription) =>
- subscription is StreamSubscription/*<T>*/
+ subscription is StreamSubscription<T>
? subscription
- : new TypeSafeStreamSubscription/*<T>*/(subscription);
+ : new TypeSafeStreamSubscription<T>(subscription);
void onData(void handleData(T data)) {
_source.onData(handleData);
@@ -51,7 +51,7 @@
Future cancel() => _source.cancel();
- Future/*<E>*/ asFuture/*<E>*/([/*=E*/ futureValue]) =>
+ Future<E> asFuture<E>([E futureValue]) =>
_source.asFuture(futureValue);
bool get isPaused => _source.isPaused;
diff --git a/lib/src/future_group.dart b/lib/src/future_group.dart
index 114c133..9b85c2f 100644
--- a/lib/src/future_group.dart
+++ b/lib/src/future_group.dart
@@ -67,19 +67,19 @@
_pending++;
task.then((value) {
- if (_completer.isCompleted) return;
+ if (_completer.isCompleted) return null;
_pending--;
_values[index] = value;
- if (_pending != 0) return;
+ if (_pending != 0) return null;
if (_onIdleController != null) _onIdleController.add(null);
- if (!_closed) return;
+ if (!_closed) return null;
if (_onIdleController != null) _onIdleController.close();
_completer.complete(_values);
}).catchError((error, stackTrace) {
- if (_completer.isCompleted) return;
+ if (_completer.isCompleted) return null;
_completer.completeError(error, stackTrace);
});
}
diff --git a/lib/src/lazy_stream.dart b/lib/src/lazy_stream.dart
index 147fa8b..ad00a03 100644
--- a/lib/src/lazy_stream.dart
+++ b/lib/src/lazy_stream.dart
@@ -43,10 +43,10 @@
Stream<T> stream;
if (result is Future) {
stream = StreamCompleter.fromFuture(result.then((stream) {
- return DelegatingStream.typed/*<T>*/(stream as Stream);
+ return DelegatingStream.typed<T>(stream as Stream);
}));
} else {
- stream = DelegatingStream.typed/*<T>*/(result as Stream);
+ stream = DelegatingStream.typed<T>(result as Stream);
}
return stream.listen(onData,
diff --git a/lib/src/result.dart b/lib/src/result.dart
index 393dced..51db558 100644
--- a/lib/src/result.dart
+++ b/lib/src/result.dart
@@ -76,10 +76,10 @@
///
/// The resulting future will never have an error.
/// Errors have been converted to an [ErrorResult] value.
- static Future<Result/*<T>*/> capture/*<T>*/(Future/*<T>*/ future) {
+ static Future<Result<T>> capture<T>(Future<T> future) {
return future.then((value) => new ValueResult(value),
onError: (error, stackTrace) =>
- new ErrorResult/*<T>*/(error, stackTrace));
+ new ErrorResult<T>(error, stackTrace));
}
/// Release the result of a captured future.
@@ -89,23 +89,23 @@
///
/// If [future] completes with an error, the returned future completes with
/// the same error.
- static Future/*<T>*/ release/*<T>*/(Future<Result/*<T>*/> future) =>
- future.then/*<Future<T>>*/((result) => result.asFuture);
+ static Future<T> release<T>(Future<Result<T>> future) =>
+ future.then<Future<T>>((result) => result.asFuture);
/// Capture the results of a stream into a stream of [Result] values.
///
/// The returned stream will not have any error events.
/// Errors from the source stream have been converted to [ErrorResult]s.
- static Stream<Result/*<T>*/> captureStream/*<T>*/(Stream/*<T>*/ source) =>
- source.transform(new CaptureStreamTransformer/*<T>*/());
+ static Stream<Result<T>> captureStream<T>(Stream<T> source) =>
+ source.transform(new CaptureStreamTransformer<T>());
/// Release a stream of [result] values into a stream of the results.
///
/// `Result` values of the source stream become value or error events in
/// the returned stream as appropriate.
/// Errors from the source stream become errors in the returned stream.
- static Stream/*<T>*/ releaseStream/*<T>*/(Stream<Result/*<T>*/> source) =>
- source.transform(new ReleaseStreamTransformer/*<T>*/());
+ static Stream<T> releaseStream<T>(Stream<Result<T>> source) =>
+ source.transform(new ReleaseStreamTransformer<T>());
/// Converts a result of a result to a single result.
///
@@ -113,9 +113,9 @@
/// which is then an error, then a result with that error is returned.
/// Otherwise both levels of results are value results, and a single
/// result with the value is returned.
- static Result/*<T>*/ flatten/*<T>*/(Result<Result/*<T>*/> result) {
+ static Result<T> flatten<T>(Result<Result<T>> result) {
if (result.isValue) return result.asValue.value;
- return new ErrorResult/*<T>*/(
+ return new ErrorResult<T>(
result.asError.error, result.asError.stackTrace);
}
diff --git a/lib/src/stream_completer.dart b/lib/src/stream_completer.dart
index 953985e..2bff6a5 100644
--- a/lib/src/stream_completer.dart
+++ b/lib/src/stream_completer.dart
@@ -34,8 +34,8 @@
///
/// If the future completes with an error, the returned stream will
/// instead contain just that error.
- static Stream/*<T>*/ fromFuture/*<T>*/(Future<Stream/*<T>*/> streamFuture) {
- var completer = new StreamCompleter/*<T>*/();
+ static Stream<T> fromFuture<T>(Future<Stream<T>> streamFuture) {
+ var completer = new StreamCompleter<T>();
streamFuture.then(completer.setSourceStream,
onError: completer.setError);
return completer.stream;
diff --git a/lib/src/stream_group.dart b/lib/src/stream_group.dart
index 889ccd8..4aa448e 100644
--- a/lib/src/stream_group.dart
+++ b/lib/src/stream_group.dart
@@ -53,8 +53,8 @@
///
/// This is equivalent to adding [streams] to a group, closing that group, and
/// returning its stream.
- static Stream/*<T>*/ merge/*<T>*/(Iterable<Stream/*<T>*/> streams) {
- var group = new StreamGroup/*<T>*/();
+ static Stream<T> merge<T>(Iterable<Stream<T>> streams) {
+ var group = new StreamGroup<T>();
streams.forEach(group.add);
group.close();
return group.stream;
diff --git a/lib/src/stream_queue.dart b/lib/src/stream_queue.dart
index 99e7436..f578081 100644
--- a/lib/src/stream_queue.dart
+++ b/lib/src/stream_queue.dart
@@ -354,10 +354,10 @@
/// CancelableOperation<String> nextStdinLine() =>
/// _stdinQueue.cancelable((queue) => queue.next);
/// ```
- CancelableOperation/*<S>*/ cancelable/*<S>*/(
- Future/*<S>*/ callback(StreamQueue<T> queue)) {
+ CancelableOperation<S> cancelable<S>(
+ Future<S> callback(StreamQueue<T> queue)) {
var transaction = startTransaction();
- var completer = new CancelableCompleter/*<S>*/(onCancel: () {
+ var completer = new CancelableCompleter<S>(onCancel: () {
transaction.reject();
});
diff --git a/lib/src/stream_sink_completer.dart b/lib/src/stream_sink_completer.dart
index 00a7086..f8056c7 100644
--- a/lib/src/stream_sink_completer.dart
+++ b/lib/src/stream_sink_completer.dart
@@ -36,9 +36,9 @@
///
/// If the future completes with an error, the returned sink will instead
/// be closed. Its [Sink.done] future will contain the error.
- static StreamSink/*<T>*/ fromFuture/*<T>*/(
- Future<StreamSink/*<T>*/> sinkFuture) {
- var completer = new StreamSinkCompleter/*<T>*/();
+ static StreamSink<T> fromFuture<T>(
+ Future<StreamSink<T>> sinkFuture) {
+ var completer = new StreamSinkCompleter<T>();
sinkFuture.then(completer.setDestinationSink,
onError: completer.setError);
return completer.sink;
diff --git a/lib/src/stream_sink_transformer.dart b/lib/src/stream_sink_transformer.dart
index d40bc4b..65adda6 100644
--- a/lib/src/stream_sink_transformer.dart
+++ b/lib/src/stream_sink_transformer.dart
@@ -54,9 +54,9 @@
/// This means that calls to [StreamSink.add] on the returned sink may throw a
/// [CastError] if the argument type doesn't match the reified type of the
/// sink.
- static StreamSinkTransformer/*<S, T>*/ typed/*<S, T>*/(
+ static StreamSinkTransformer<S, T> typed<S, T>(
StreamSinkTransformer transformer) =>
- transformer is StreamSinkTransformer/*<S, T>*/
+ transformer is StreamSinkTransformer<S, T>
? transformer
: new TypeSafeStreamSinkTransformer(transformer);
}
diff --git a/lib/src/stream_splitter.dart b/lib/src/stream_splitter.dart
index 448fe2a..3d8f994 100644
--- a/lib/src/stream_splitter.dart
+++ b/lib/src/stream_splitter.dart
@@ -57,10 +57,10 @@
///
/// [count] defaults to 2. This is the same as creating [count] branches and
/// then closing the [StreamSplitter].
- static List<Stream/*<T>*/> splitFrom/*<T>*/(Stream/*<T>*/ stream,
+ static List<Stream<T>> splitFrom<T>(Stream<T> stream,
[int count]) {
if (count == null) count = 2;
- var splitter = new StreamSplitter/*<T>*/(stream);
+ var splitter = new StreamSplitter<T>(stream);
var streams = new List<Stream>.generate(count, (_) => splitter.split());
splitter.close();
return streams;
diff --git a/lib/src/stream_subscription_transformer.dart b/lib/src/stream_subscription_transformer.dart
index c13341c..ad54539 100644
--- a/lib/src/stream_subscription_transformer.dart
+++ b/lib/src/stream_subscription_transformer.dart
@@ -27,10 +27,10 @@
/// synchronously call the corresponding method** on the inner
/// [StreamSubscription]: [handleCancel] must call `cancel()`, [handlePause]
/// must call `pause()`, and [handleResume] must call `resume()`.
-StreamTransformer/*<T, T>*/ subscriptionTransformer/*<T>*/(
- {Future handleCancel(StreamSubscription/*<T>*/ inner),
- void handlePause(StreamSubscription/*<T>*/ inner),
- void handleResume(StreamSubscription/*<T>*/ inner)}) {
+StreamTransformer<T, T> subscriptionTransformer<T>(
+ {Future handleCancel(StreamSubscription<T> inner),
+ void handlePause(StreamSubscription<T> inner),
+ void handleResume(StreamSubscription<T> inner)}) {
return new StreamTransformer((stream, cancelOnError) {
return new _TransformedSubscription(
stream.listen(null, cancelOnError: cancelOnError),
@@ -99,6 +99,6 @@
_handleResume(_inner);
}
- Future/*<E>*/ asFuture/*<E>*/([/*=E*/ futureValue]) =>
- _inner?.asFuture(futureValue) ?? new Completer/*<E>*/().future;
+ Future<E> asFuture<E>([E futureValue]) =>
+ _inner?.asFuture(futureValue) ?? new Completer<E>().future;
}
diff --git a/lib/src/typed/future.dart b/lib/src/typed/future.dart
index 995f4b5..4630af7 100644
--- a/lib/src/typed/future.dart
+++ b/lib/src/typed/future.dart
@@ -14,7 +14,7 @@
Future<T> catchError(Function onError, {bool test(Object error)}) async =>
new TypeSafeFuture<T>(_future.catchError(onError, test: test));
- Future/*<S>*/ then/*<S>*/(dynamic onValue(T value), {Function onError}) =>
+ Future<S> then<S>(dynamic onValue(T value), {Function onError}) =>
_future.then((value) => onValue(value as T), onError: onError);
Future<T> whenComplete(action()) =>
diff --git a/lib/src/typed/stream.dart b/lib/src/typed/stream.dart
index afa4462..235b205 100644
--- a/lib/src/typed/stream.dart
+++ b/lib/src/typed/stream.dart
@@ -37,10 +37,10 @@
onCancel(new TypeSafeStreamSubscription<T>(subscription))));
}
- Stream/*<E>*/ asyncExpand/*<E>*/(Stream/*<E>*/ convert(T event)) =>
+ Stream<E> asyncExpand<E>(Stream<E> convert(T event)) =>
_stream.asyncExpand(_validateType(convert));
- Stream/*<E>*/ asyncMap/*<E>*/(convert(T event)) =>
+ Stream<E> asyncMap<E>(convert(T event)) =>
_stream.asyncMap(_validateType(convert));
Stream<T> distinct([bool equals(T previous, T next)]) =>
@@ -48,10 +48,10 @@
? null
: (previous, next) => equals(previous as T, next as T)));
- Future/*<E>*/ drain/*<E>*/([/*=E*/ futureValue]) =>
+ Future<E> drain<E>([E futureValue]) =>
_stream.drain(futureValue);
- Stream/*<S>*/ expand/*<S>*/(Iterable/*<S>*/ convert(T value)) =>
+ Stream<S> expand<S>(Iterable<S> convert(T value)) =>
_stream.expand(_validateType(convert));
Future firstWhere(bool test(T element), {Object defaultValue()}) =>
@@ -63,8 +63,8 @@
Future<T> singleWhere(bool test(T element)) async =>
(await _stream.singleWhere(_validateType(test))) as T;
- Future/*<S>*/ fold/*<S>*/(/*=S*/ initialValue,
- /*=S*/ combine(/*=S*/ previous, T element)) =>
+ Future<S> fold<S>(S initialValue,
+ S combine(S previous, T element)) =>
_stream.fold(initialValue,
(previous, element) => combine(previous, element as T));
@@ -79,7 +79,7 @@
new TypeSafeStreamSubscription<T>(_stream.listen(_validateType(onData),
onError: onError, onDone: onDone, cancelOnError: cancelOnError));
- Stream/*<S>*/ map/*<S>*/(/*=S*/ convert(T event)) =>
+ Stream<S> map<S>(S convert(T event)) =>
_stream.map(_validateType(convert));
// Don't forward to `_stream.pipe` because we want the consumer to see the
@@ -105,15 +105,15 @@
onTimeout: (sink) => onTimeout(DelegatingEventSink.typed(sink))));
Future<List<T>> toList() async =>
- DelegatingList.typed/*<T>*/(await _stream.toList());
+ DelegatingList.typed<T>(await _stream.toList());
Future<Set<T>> toSet() async =>
- DelegatingSet.typed/*<T>*/(await _stream.toSet());
+ DelegatingSet.typed<T>(await _stream.toSet());
// Don't forward to `_stream.transform` because we want the transformer to see
// the type-asserted stream.
- Stream/*<S>*/ transform/*<S>*/(
- StreamTransformer<T, dynamic/*=S*/> transformer) =>
+ Stream<S> transform<S>(
+ StreamTransformer<T, S> transformer) =>
transformer.bind(this);
Stream<T> where(bool test(T element)) =>
@@ -132,7 +132,7 @@
/// Returns a version of [function] that asserts that its argument is an
/// instance of `T`.
- UnaryFunction/*<dynamic, S>*/ _validateType/*<S>*/(
- /*=S*/ function(T value)) =>
+ UnaryFunction<dynamic, S> _validateType<S>(
+ S function(T value)) =>
function == null ? null : (value) => function(value as T);
}
diff --git a/lib/src/typed/stream_subscription.dart b/lib/src/typed/stream_subscription.dart
index 2cd4ddf..e02e1c0 100644
--- a/lib/src/typed/stream_subscription.dart
+++ b/lib/src/typed/stream_subscription.dart
@@ -33,6 +33,6 @@
Future cancel() => _subscription.cancel();
- Future/*<E>*/ asFuture/*<E>*/([/*=E*/ futureValue]) =>
+ Future<E> asFuture<E>([E futureValue]) =>
_subscription.asFuture(futureValue);
}
diff --git a/lib/src/typed_stream_transformer.dart b/lib/src/typed_stream_transformer.dart
index 2fb20c4..98d5e70 100644
--- a/lib/src/typed_stream_transformer.dart
+++ b/lib/src/typed_stream_transformer.dart
@@ -12,9 +12,9 @@
/// regardless of its original generic type, by asserting that the events
/// emitted by the transformed stream are instances of `T` whenever they're
/// provided. If they're not, the stream throws a [CastError].
-StreamTransformer/*<S, T>*/ typedStreamTransformer/*<S, T>*/(
+StreamTransformer<S, T> typedStreamTransformer<S, T>(
StreamTransformer transformer) =>
- transformer is StreamTransformer/*<S, T>*/
+ transformer is StreamTransformer<S, T>
? transformer
: new _TypeSafeStreamTransformer(transformer);
diff --git a/pubspec.yaml b/pubspec.yaml
index 6fce524..ea64ad7 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: async
-version: 1.13.0
+version: 1.13.1-dev
author: Dart Team <misc@dartlang.org>
description: Utility functions and classes related to the 'dart:async' library.
homepage: https://www.github.com/dart-lang/async