Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2765)

Unified Diff: corelib/src/implementation/future_implementation.dart

Issue 10255015: Handle an exception handler returning null more gracefully. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/implementation/future_implementation.dart
diff --git a/corelib/src/implementation/future_implementation.dart b/corelib/src/implementation/future_implementation.dart
index f2d73a337f7563922bd62c5f186fd6634a5471c3..88cd0f24134708712b54d654c95eee4be1e2a760 100644
--- a/corelib/src/implementation/future_implementation.dart
+++ b/corelib/src/implementation/future_implementation.dart
@@ -1,9 +1,9 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
+// Copyright 2012 Google Inc. All Rights Reserved.
// Dart core library.
class FutureImpl<T> implements Future<T> {
- bool _isComplete;
+ bool _isComplete = false;
/**
* Value that was provided to this Future by the Completer
@@ -19,7 +19,7 @@ class FutureImpl<T> implements Future<T> {
/**
* true, if any onException handler handled the exception.
*/
- bool _exceptionHandled;
+ bool _exceptionHandled = false;
Siggi Cherem (dart-lang) 2012/04/27 22:32:51 yay!
/**
* Listeners waiting to receive the value of this future.
@@ -31,10 +31,9 @@ class FutureImpl<T> implements Future<T> {
*/
final List<Function> _exceptionHandlers;
- FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() {
- _isComplete = false;
- _exceptionHandled = false;
- }
+ FutureImpl()
+ : _listeners = [],
+ _exceptionHandlers = [];
factory FutureImpl.immediate(T value) {
final res = new FutureImpl();
@@ -92,12 +91,15 @@ class FutureImpl<T> implements Future<T> {
_isComplete = true;
if (_exception !== null) {
for (Function handler in _exceptionHandlers) {
- if (handler(_exception)) {
+ // Explicitly check for true here so that if the handler returns null,
Siggi Cherem (dart-lang) 2012/04/27 22:32:51 booo! :(
+ // we don't get an exception in checked mode.
+ if (handler(_exception) == true) {
_exceptionHandled = true;
break;
}
}
}
+
if (hasValue) {
for (Function listener in _listeners) {
listener(value);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698