@@ -322,15 +322,16 @@ Set<String> createDirectoryFilter(Iterable<String> dirs) {
322
322
/// Returns the maximum value in [iter] by [compare] .
323
323
///
324
324
/// [compare] defaults to [Comparable.compare] .
325
- T maxAll <T >(Iterable <T > iter, [int compare (T value, T value2)]) {
326
- compare ?? = (value1, value2) => (value1 as Comparable ).compareTo (value2);
325
+ T maxAll <T extends Comparable >(Iterable <T > iter,
326
+ [int compare (T element1, T element2)]) {
327
+ if (compare == null ) compare = Comparable .compare;
327
328
return iter
328
329
.reduce ((max, element) => compare (element, max) > 0 ? element : max);
329
330
}
330
331
331
332
/// Replace each instance of [matcher] in [source] with the return value of
332
333
/// [fn] .
333
- String replace (String source, Pattern matcher, String fn (Match )) {
334
+ String replace (String source, Pattern matcher, String fn (Match match )) {
334
335
var buffer = new StringBuffer ();
335
336
var start = 0 ;
336
337
for (var match in matcher.allMatches (source)) {
@@ -399,7 +400,7 @@ Future<Stream<T>> validateStream<T>(Stream<T> stream) {
399
400
// We got a value, so the stream is valid.
400
401
if (! completer.isCompleted) completer.complete (controller.stream);
401
402
controller.add (value);
402
- }, onError: (error, [stackTrace]) {
403
+ }, onError: (error, [StackTrace stackTrace]) {
403
404
// If the error came after values, it's OK.
404
405
if (completer.isCompleted) {
405
406
controller.addError (error, stackTrace);
@@ -425,13 +426,13 @@ Future<Stream<T>> validateStream<T>(Stream<T> stream) {
425
426
/// Returns a [Future] that will complete to the first element of [stream] .
426
427
///
427
428
/// Unlike [Stream.first] , this is safe to use with single-subscription streams.
428
- Future streamFirst (Stream stream) {
429
+ Future < T > streamFirst < T > (Stream < T > stream) {
429
430
var completer = new Completer ();
430
431
var subscription;
431
432
subscription = stream.listen ((value) {
432
433
subscription.cancel ();
433
434
completer.complete (value);
434
- }, onError: (e, [stackTrace]) {
435
+ }, onError: (e, [StackTrace stackTrace]) {
435
436
completer.completeError (e, stackTrace);
436
437
}, onDone: () {
437
438
completer.completeError (new StateError ("No elements" ), new Chain .current ());
0 commit comments