Skip to content

Commit a13bf1d

Browse files
authored
Tighten up types (#1776)
1 parent d1289ab commit a13bf1d

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lib/src/barback/load_all_transformers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ List<Set<TransformerId>> _stageTransformers(
133133
var stageNumbers = <TransformerId, int>{};
134134
var stages = <Set<TransformerId>>[];
135135

136-
stageNumberFor(TransformerId id) {
136+
int stageNumberFor(TransformerId id) {
137137
// Built-in transformers don't have to be loaded in stages, since they're
138138
// run from pub's source. Return -1 so that the "next stage" is 0.
139139
if (id.isBuiltInTransformer) return -1;

lib/src/io.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void _attempt(String description, void operation()) {
354354
return;
355355
}
356356

357-
getErrorReason(error) {
357+
String getErrorReason(FileSystemException error) {
358358
if (error.osError.errorCode == 5) {
359359
return "access was denied";
360360
}

lib/src/utils.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,16 @@ Set<String> createDirectoryFilter(Iterable<String> dirs) {
322322
/// Returns the maximum value in [iter] by [compare].
323323
///
324324
/// [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;
327328
return iter
328329
.reduce((max, element) => compare(element, max) > 0 ? element : max);
329330
}
330331

331332
/// Replace each instance of [matcher] in [source] with the return value of
332333
/// [fn].
333-
String replace(String source, Pattern matcher, String fn(Match)) {
334+
String replace(String source, Pattern matcher, String fn(Match match)) {
334335
var buffer = new StringBuffer();
335336
var start = 0;
336337
for (var match in matcher.allMatches(source)) {
@@ -399,7 +400,7 @@ Future<Stream<T>> validateStream<T>(Stream<T> stream) {
399400
// We got a value, so the stream is valid.
400401
if (!completer.isCompleted) completer.complete(controller.stream);
401402
controller.add(value);
402-
}, onError: (error, [stackTrace]) {
403+
}, onError: (error, [StackTrace stackTrace]) {
403404
// If the error came after values, it's OK.
404405
if (completer.isCompleted) {
405406
controller.addError(error, stackTrace);
@@ -425,13 +426,13 @@ Future<Stream<T>> validateStream<T>(Stream<T> stream) {
425426
/// Returns a [Future] that will complete to the first element of [stream].
426427
///
427428
/// 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) {
429430
var completer = new Completer();
430431
var subscription;
431432
subscription = stream.listen((value) {
432433
subscription.cancel();
433434
completer.complete(value);
434-
}, onError: (e, [stackTrace]) {
435+
}, onError: (e, [StackTrace stackTrace]) {
435436
completer.completeError(e, stackTrace);
436437
}, onDone: () {
437438
completer.completeError(new StateError("No elements"), new Chain.current());

0 commit comments

Comments
 (0)