 Chromium Code Reviews
 Chromium Code Reviews Issue 1841223002:
  Fix most strong mode warnings.  (Closed) 
  Base URL: git@github.com:dart-lang/async.git@master
    
  
    Issue 1841223002:
  Fix most strong mode warnings.  (Closed) 
  Base URL: git@github.com:dart-lang/async.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 import 'dart:async'; | 5 import 'dart:async'; | 
| 6 | 6 | 
| 7 import '../result.dart'; | 7 import '../result.dart'; | 
| 8 import 'value.dart'; | 8 import 'value.dart'; | 
| 9 | 9 | 
| 10 /// A result representing a thrown error. | 10 /// A result representing a thrown error. | 
| 11 class ErrorResult implements Result { | 11 class ErrorResult<T> implements Result<T> { | 
| 
Lasse Reichstein Nielsen
2016/03/29 21:53:59
I really dislike adding <T> here - it's completely
 
nweiz
2016/03/30 00:57:18
I understand the logic behind this being a Result<
 | |
| 12 final error; | 12 final error; | 
| 13 final StackTrace stackTrace; | 13 final StackTrace stackTrace; | 
| 14 | 14 | 
| 15 bool get isValue => false; | 15 bool get isValue => false; | 
| 16 bool get isError => true; | 16 bool get isError => true; | 
| 17 ValueResult get asValue => null; | 17 ValueResult<T> get asValue => null; | 
| 18 ErrorResult get asError => this; | 18 ErrorResult<T> get asError => this; | 
| 19 | 19 | 
| 20 ErrorResult(this.error, this.stackTrace); | 20 ErrorResult(this.error, this.stackTrace); | 
| 21 | 21 | 
| 22 void complete(Completer completer) { | 22 void complete(Completer completer) { | 
| 23 completer.completeError(error, stackTrace); | 23 completer.completeError(error, stackTrace); | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 void addTo(EventSink sink) { | 26 void addTo(EventSink sink) { | 
| 27 sink.addError(error, stackTrace); | 27 sink.addError(error, stackTrace); | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 Future get asFuture => new Future.error(error, stackTrace); | 30 Future<T> get asFuture => new Future.error(error, stackTrace); | 
| 
Lasse Reichstein Nielsen
2016/03/29 21:53:59
Should this be  new Future<T>.error ?
(Then, at le
 
nweiz
2016/03/30 00:57:18
That's inferred via downward inference.
 
Lasse Reichstein Nielsen
2016/03/30 16:00:18
That doesn't work in the VM or pure Dart.
This co
 
nweiz
2016/03/30 19:11:54
I'm not sure what you mean by "pure Dart", but thi
 | |
| 31 | 31 | 
| 32 /// Calls an error handler with the error and stacktrace. | 32 /// Calls an error handler with the error and stacktrace. | 
| 33 /// | 33 /// | 
| 34 /// An async error handler function is either a function expecting two | 34 /// An async error handler function is either a function expecting two | 
| 35 /// arguments, which will be called with the error and the stack trace, or it | 35 /// arguments, which will be called with the error and the stack trace, or it | 
| 36 /// has to be a function expecting only one argument, which will be called | 36 /// has to be a function expecting only one argument, which will be called | 
| 37 /// with only the error. | 37 /// with only the error. | 
| 38 void handle(Function errorHandler) { | 38 void handle(Function errorHandler) { | 
| 39 if (errorHandler is ZoneBinaryCallback) { | 39 if (errorHandler is ZoneBinaryCallback) { | 
| 40 errorHandler(error, stackTrace); | 40 errorHandler(error, stackTrace); | 
| 41 } else { | 41 } else { | 
| 42 errorHandler(error); | 42 errorHandler(error); | 
| 43 } | 43 } | 
| 44 } | 44 } | 
| 45 } | 45 } | 
| OLD | NEW |