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

Side by Side Diff: test/dart_codegen/expect/async/future_impl.dart

Issue 1038583004: Rationalize coercions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 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 unified diff | Download patch
OLDNEW
1 part of dart.async; 1 part of dart.async;
2 typedef dynamic _FutureOnValue<T>(T value); 2 typedef dynamic _FutureOnValue<T>(T value);
3 typedef bool _FutureErrorTest(var error); 3 typedef bool _FutureErrorTest(var error);
4 typedef _FutureAction(); 4 typedef _FutureAction();
5 abstract class _Completer<T> implements Completer<T> {final _Future<T> future = new _Future<T>(); 5 abstract class _Completer<T> implements Completer<T> {final _Future<T> future = new _Future<T>();
6 void complete([value]); 6 void complete([value]);
7 void completeError(Object error, [StackTrace stackTrace]) { 7 void completeError(Object error, [StackTrace stackTrace]) {
8 error = _nonNullError(error); 8 error = _nonNullError(error);
9 if (!future._mayComplete) throw new StateError("Future already completed"); 9 if (!future._mayComplete) throw new StateError("Future already completed");
10 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); 10 AsyncError replacement = Zone.current.errorCallback(error, stackTrace);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 _FutureListener.then(this.result, _FutureOnValue onValue, Function errorCallbac k) : callback = onValue, errorCallback = errorCallback, state = (errorCallback = = null) ? STATE_THEN : STATE_THEN_ONERROR; 51 _FutureListener.then(this.result, _FutureOnValue onValue, Function errorCallbac k) : callback = onValue, errorCallback = errorCallback, state = (errorCallback = = null) ? STATE_THEN : STATE_THEN_ONERROR;
52 _FutureListener.catchError(this.result, this.errorCallback, _FutureErrorTest te st) : callback = test, state = (test == null) ? STATE_CATCHERROR : STATE_CATCHER ROR_TEST; 52 _FutureListener.catchError(this.result, this.errorCallback, _FutureErrorTest te st) : callback = test, state = (test == null) ? STATE_CATCHERROR : STATE_CATCHER ROR_TEST;
53 _FutureListener.whenComplete(this.result, _FutureAction onComplete) : callback = onComplete, errorCallback = null, state = STATE_WHENCOMPLETE; 53 _FutureListener.whenComplete(this.result, _FutureAction onComplete) : callback = onComplete, errorCallback = null, state = STATE_WHENCOMPLETE;
54 _FutureListener.chain(this.result) : callback = null, errorCallback = null, sta te = STATE_CHAIN; 54 _FutureListener.chain(this.result) : callback = null, errorCallback = null, sta te = STATE_CHAIN;
55 Zone get _zone => result._zone; 55 Zone get _zone => result._zone;
56 bool get handlesValue => (state & MASK_VALUE != 0); 56 bool get handlesValue => (state & MASK_VALUE != 0);
57 bool get handlesError => (state & MASK_ERROR != 0); 57 bool get handlesError => (state & MASK_ERROR != 0);
58 bool get hasErrorTest => (state == STATE_CATCHERROR_TEST); 58 bool get hasErrorTest => (state == STATE_CATCHERROR_TEST);
59 bool get handlesComplete => (state == STATE_WHENCOMPLETE); 59 bool get handlesComplete => (state == STATE_WHENCOMPLETE);
60 _FutureOnValue get _onValue { 60 _FutureOnValue get _onValue {
61 assert (handlesValue); return DEVC$RT.cast(callback, Function, __t14, "CastGener al", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __t 14, true); 61 assert (handlesValue); return DEVC$RT.cast(callback, Function, __t14, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t14, true);
62 } 62 }
63 Function get _onError => errorCallback; 63 Function get _onError => errorCallback;
64 _FutureErrorTest get _errorTest { 64 _FutureErrorTest get _errorTest {
65 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, __t16, "CastGener al", """line 117, column 12 of dart:async/future_impl.dart: """, callback is __t 16, false); 65 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, __t16, "Composite Cast", """line 117, column 12 of dart:async/future_impl.dart: """, callback is _ _t16, false);
66 } 66 }
67 _FutureAction get _whenCompleteAction { 67 _FutureAction get _whenCompleteAction {
68 assert (handlesComplete); return DEVC$RT.cast(callback, Function, __t18, "CastGe neral", """line 121, column 12 of dart:async/future_impl.dart: """, callback is __t18, true); 68 assert (handlesComplete); return DEVC$RT.cast(callback, Function, __t18, "Implic itCast", """line 121, column 12 of dart:async/future_impl.dart: """, callback is __t18, true);
69 } 69 }
70 } 70 }
71 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0; 71 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0;
72 static const int _PENDING_COMPLETE = 1; 72 static const int _PENDING_COMPLETE = 1;
73 static const int _CHAINED = 2; 73 static const int _CHAINED = 2;
74 static const int _VALUE = 4; 74 static const int _VALUE = 4;
75 static const int _ERROR = 8; 75 static const int _ERROR = 8;
76 int _state = _INCOMPLETE; 76 int _state = _INCOMPLETE;
77 final Zone _zone = Zone.current; 77 final Zone _zone = Zone.current;
78 var _resultOrListeners; 78 var _resultOrListeners;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 Future<T> whenComplete(action()) { 133 Future<T> whenComplete(action()) {
134 _Future result = new _Future<T>(); 134 _Future result = new _Future<T>();
135 if (!identical(result._zone, _ROOT_ZONE)) { 135 if (!identical(result._zone, _ROOT_ZONE)) {
136 action = result._zone.registerCallback(action); 136 action = result._zone.registerCallback(action);
137 } 137 }
138 _addListener(new _FutureListener.whenComplete(result, action)); 138 _addListener(new _FutureListener.whenComplete(result, action));
139 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) { 139 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) {
140 } 140 }
141 ), DEVC$RT.type((Future<T> _) { 141 ), DEVC$RT.type((Future<T> _) {
142 } 142 }
143 ), "CastDynamic", """line 233, column 12 of dart:async/future_impl.dart: """, re sult is Future<T>, false); 143 ), "CompositeCast", """line 233, column 12 of dart:async/future_impl.dart: """, result is Future<T>, false);
144 } 144 }
145 Stream<T> asStream() => ((__x26) => DEVC$RT.cast(__x26, DEVC$RT.type((Stream<dy namic> _) { 145 Stream<T> asStream() => ((__x26) => DEVC$RT.cast(__x26, DEVC$RT.type((Stream<dy namic> _) {
146 } 146 }
147 ), DEVC$RT.type((Stream<T> _) { 147 ), DEVC$RT.type((Stream<T> _) {
148 } 148 }
149 ), "CastExact", """line 236, column 27 of dart:async/future_impl.dart: """, __x2 6 is Stream<T>, false))(new Stream.fromFuture(this)); 149 ), "InferableAllocation", """line 236, column 27 of dart:async/future_impl.dart: """, __x26 is Stream<T>, false))(new Stream.fromFuture(this));
150 void _markPendingCompletion() { 150 void _markPendingCompletion() {
151 if (!_mayComplete) throw new StateError("Future already completed"); 151 if (!_mayComplete) throw new StateError("Future already completed");
152 _state = _PENDING_COMPLETE; 152 _state = _PENDING_COMPLETE;
153 } 153 }
154 T get _value { 154 T get _value {
155 assert (_isComplete && _hasValue); return DEVC$RT.cast(_resultOrListeners, dynam ic, T, "CastGeneral", """line 245, column 12 of dart:async/future_impl.dart: """ , _resultOrListeners is T, false); 155 assert (_isComplete && _hasValue); return DEVC$RT.cast(_resultOrListeners, dynam ic, T, "CompositeCast", """line 245, column 12 of dart:async/future_impl.dart: " "", _resultOrListeners is T, false);
156 } 156 }
157 AsyncError get _error { 157 AsyncError get _error {
158 assert (_isComplete && _hasError); return DEVC$RT.cast(_resultOrListeners, dynam ic, AsyncError, "CastGeneral", """line 250, column 12 of dart:async/future_impl. dart: """, _resultOrListeners is AsyncError, true); 158 assert (_isComplete && _hasError); return DEVC$RT.cast(_resultOrListeners, dynam ic, AsyncError, "DynamicCast", """line 250, column 12 of dart:async/future_impl. dart: """, _resultOrListeners is AsyncError, true);
159 } 159 }
160 void _setValue(T value) { 160 void _setValue(T value) {
161 assert (!_isComplete); _state = _VALUE; 161 assert (!_isComplete); _state = _VALUE;
162 _resultOrListeners = value; 162 _resultOrListeners = value;
163 } 163 }
164 void _setErrorObject(AsyncError error) { 164 void _setErrorObject(AsyncError error) {
165 assert (!_isComplete); _state = _ERROR; 165 assert (!_isComplete); _state = _ERROR;
166 _resultOrListeners = error; 166 _resultOrListeners = error;
167 } 167 }
168 void _setError(Object error, StackTrace stackTrace) { 168 void _setError(Object error, StackTrace stackTrace) {
169 _setErrorObject(new AsyncError(error, stackTrace)); 169 _setErrorObject(new AsyncError(error, stackTrace));
170 } 170 }
171 void _addListener(_FutureListener listener) { 171 void _addListener(_FutureListener listener) {
172 assert (listener._nextListener == null); if (_isComplete) { 172 assert (listener._nextListener == null); if (_isComplete) {
173 _zone.scheduleMicrotask(() { 173 _zone.scheduleMicrotask(() {
174 _propagateToListeners(this, listener); 174 _propagateToListeners(this, listener);
175 } 175 }
176 ); 176 );
177 } 177 }
178 else { 178 else {
179 listener._nextListener = DEVC$RT.cast(_resultOrListeners, dynamic, _FutureListen er, "CastGeneral", """line 277, column 32 of dart:async/future_impl.dart: """, _ resultOrListeners is _FutureListener, true); 179 listener._nextListener = DEVC$RT.cast(_resultOrListeners, dynamic, _FutureListen er, "DynamicCast", """line 277, column 32 of dart:async/future_impl.dart: """, _ resultOrListeners is _FutureListener, true);
180 _resultOrListeners = listener; 180 _resultOrListeners = listener;
181 } 181 }
182 } 182 }
183 _FutureListener _removeListeners() { 183 _FutureListener _removeListeners() {
184 assert (!_isComplete); _FutureListener current = DEVC$RT.cast(_resultOrListeners , dynamic, _FutureListener, "CastGeneral", """line 286, column 31 of dart:async/ future_impl.dart: """, _resultOrListeners is _FutureListener, true); 184 assert (!_isComplete); _FutureListener current = DEVC$RT.cast(_resultOrListeners , dynamic, _FutureListener, "DynamicCast", """line 286, column 31 of dart:async/ future_impl.dart: """, _resultOrListeners is _FutureListener, true);
185 _resultOrListeners = null; 185 _resultOrListeners = null;
186 _FutureListener prev = null; 186 _FutureListener prev = null;
187 while (current != null) { 187 while (current != null) {
188 _FutureListener next = current._nextListener; 188 _FutureListener next = current._nextListener;
189 current._nextListener = prev; 189 current._nextListener = prev;
190 prev = current; 190 prev = current;
191 current = next; 191 current = next;
192 } 192 }
193 return prev; 193 return prev;
194 } 194 }
195 static void _chainForeignFuture(Future source, _Future target) { 195 static void _chainForeignFuture(Future source, _Future target) {
196 assert (!target._isComplete); assert (source is! _Future); target._isChained = t rue; 196 assert (!target._isComplete); assert (source is! _Future); target._isChained = t rue;
197 source.then((value) { 197 source.then((value) {
198 assert (target._isChained); target._completeWithValue(value); 198 assert (target._isChained); target._completeWithValue(value);
199 } 199 }
200 , onError: (error, [stackTrace]) { 200 , onError: (error, [stackTrace]) {
201 assert (target._isChained); target._completeError(error, DEVC$RT.cast(stackTrace , dynamic, StackTrace, "CastGeneral", """line 317, column 38 of dart:async/futur e_impl.dart: """, stackTrace is StackTrace, true)); 201 assert (target._isChained); target._completeError(error, DEVC$RT.cast(stackTrace , dynamic, StackTrace, "DynamicCast", """line 317, column 38 of dart:async/futur e_impl.dart: """, stackTrace is StackTrace, true));
202 } 202 }
203 ); 203 );
204 } 204 }
205 static void _chainCoreFuture(_Future source, _Future target) { 205 static void _chainCoreFuture(_Future source, _Future target) {
206 assert (!target._isComplete); assert (source is _Future); target._isChained = tr ue; 206 assert (!target._isComplete); assert (source is _Future); target._isChained = tr ue;
207 _FutureListener listener = new _FutureListener.chain(target); 207 _FutureListener listener = new _FutureListener.chain(target);
208 if (source._isComplete) { 208 if (source._isComplete) {
209 _propagateToListeners(source, listener); 209 _propagateToListeners(source, listener);
210 } 210 }
211 else { 211 else {
212 source._addListener(listener); 212 source._addListener(listener);
213 } 213 }
214 } 214 }
215 void _complete(value) { 215 void _complete(value) {
216 assert (!_isComplete); if (value is Future) { 216 assert (!_isComplete); if (value is Future) {
217 if (value is _Future) { 217 if (value is _Future) {
218 _chainCoreFuture(DEVC$RT.cast(value, dynamic, DEVC$RT.type((_Future<dynamic> _) { 218 _chainCoreFuture(DEVC$RT.cast(value, dynamic, DEVC$RT.type((_Future<dynamic> _) {
219 } 219 }
220 ), "CastGeneral", """line 341, column 26 of dart:async/future_impl.dart: """, va lue is _Future<dynamic>, true), this); 220 ), "DynamicCast", """line 341, column 26 of dart:async/future_impl.dart: """, va lue is _Future<dynamic>, true), this);
221 } 221 }
222 else { 222 else {
223 _chainForeignFuture(DEVC$RT.cast(value, dynamic, DEVC$RT.type((Future<dynamic> _ ) { 223 _chainForeignFuture(DEVC$RT.cast(value, dynamic, DEVC$RT.type((Future<dynamic> _ ) {
224 } 224 }
225 ), "CastGeneral", """line 343, column 29 of dart:async/future_impl.dart: """, va lue is Future<dynamic>, true), this); 225 ), "DynamicCast", """line 343, column 29 of dart:async/future_impl.dart: """, va lue is Future<dynamic>, true), this);
226 } 226 }
227 } 227 }
228 else { 228 else {
229 _FutureListener listeners = _removeListeners(); 229 _FutureListener listeners = _removeListeners();
230 _setValue(DEVC$RT.cast(value, dynamic, T, "CastGeneral", """line 347, column 17 of dart:async/future_impl.dart: """, value is T, false)); 230 _setValue(DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 347, column 17 of dart:async/future_impl.dart: """, value is T, false));
231 _propagateToListeners(this, listeners); 231 _propagateToListeners(this, listeners);
232 } 232 }
233 } 233 }
234 void _completeWithValue(value) { 234 void _completeWithValue(value) {
235 assert (!_isComplete); assert (value is! Future); _FutureListener listeners = _r emoveListeners(); 235 assert (!_isComplete); assert (value is! Future); _FutureListener listeners = _r emoveListeners();
236 _setValue(DEVC$RT.cast(value, dynamic, T, "CastGeneral", """line 357, column 15 of dart:async/future_impl.dart: """, value is T, false)); 236 _setValue(DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 357, column 15 of dart:async/future_impl.dart: """, value is T, false));
237 _propagateToListeners(this, listeners); 237 _propagateToListeners(this, listeners);
238 } 238 }
239 void _completeError(error, [StackTrace stackTrace]) { 239 void _completeError(error, [StackTrace stackTrace]) {
240 assert (!_isComplete); _FutureListener listeners = _removeListeners(); 240 assert (!_isComplete); _FutureListener listeners = _removeListeners();
241 _setError(error, stackTrace); 241 _setError(error, stackTrace);
242 _propagateToListeners(this, listeners); 242 _propagateToListeners(this, listeners);
243 } 243 }
244 void _asyncComplete(value) { 244 void _asyncComplete(value) {
245 assert (!_isComplete); if (value == null) { 245 assert (!_isComplete); if (value == null) {
246 } 246 }
247 else if (value is Future) { 247 else if (value is Future) {
248 Future<T> typedFuture = DEVC$RT.cast(value, dynamic, DEVC$RT.type((Future<T> _) { 248 Future<T> typedFuture = DEVC$RT.cast(value, dynamic, DEVC$RT.type((Future<T> _) {
249 } 249 }
250 ), "CastGeneral", """line 386, column 31 of dart:async/future_impl.dart: """, va lue is Future<T>, false); 250 ), "CompositeCast", """line 386, column 31 of dart:async/future_impl.dart: """, value is Future<T>, false);
251 if (typedFuture is _Future) { 251 if (typedFuture is _Future) {
252 _Future<T> coreFuture = DEVC$RT.cast(typedFuture, DEVC$RT.type((Future<T> _) { 252 _Future<T> coreFuture = DEVC$RT.cast(typedFuture, DEVC$RT.type((Future<T> _) {
253 } 253 }
254 ), DEVC$RT.type((_Future<T> _) { 254 ), DEVC$RT.type((_Future<T> _) {
255 } 255 }
256 ), "CastGeneral", """line 388, column 33 of dart:async/future_impl.dart: """, ty pedFuture is _Future<T>, false); 256 ), "CompositeCast", """line 388, column 33 of dart:async/future_impl.dart: """, typedFuture is _Future<T>, false);
257 if (coreFuture._isComplete && coreFuture._hasError) { 257 if (coreFuture._isComplete && coreFuture._hasError) {
258 _markPendingCompletion(); 258 _markPendingCompletion();
259 _zone.scheduleMicrotask(() { 259 _zone.scheduleMicrotask(() {
260 _chainCoreFuture(coreFuture, this); 260 _chainCoreFuture(coreFuture, this);
261 } 261 }
262 ); 262 );
263 } 263 }
264 else { 264 else {
265 _chainCoreFuture(coreFuture, this); 265 _chainCoreFuture(coreFuture, this);
266 } 266 }
267 } 267 }
268 else { 268 else {
269 _chainForeignFuture(typedFuture, this); 269 _chainForeignFuture(typedFuture, this);
270 } 270 }
271 return;} 271 return;}
272 else { 272 else {
273 T typedValue = DEVC$RT.cast(value, dynamic, T, "CastGeneral", """line 407, colum n 22 of dart:async/future_impl.dart: """, value is T, false); 273 T typedValue = DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 407, col umn 22 of dart:async/future_impl.dart: """, value is T, false);
274 } 274 }
275 _markPendingCompletion(); 275 _markPendingCompletion();
276 _zone.scheduleMicrotask(() { 276 _zone.scheduleMicrotask(() {
277 _completeWithValue(value); 277 _completeWithValue(value);
278 } 278 }
279 ); 279 );
280 } 280 }
281 void _asyncCompleteError(error, StackTrace stackTrace) { 281 void _asyncCompleteError(error, StackTrace stackTrace) {
282 assert (!_isComplete); _markPendingCompletion(); 282 assert (!_isComplete); _markPendingCompletion();
283 _zone.scheduleMicrotask(() { 283 _zone.scheduleMicrotask(() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 listenerValueOrError = new AsyncError(e, s); 324 listenerValueOrError = new AsyncError(e, s);
325 return false; 325 return false;
326 } 326 }
327 } 327 }
328 void handleError() { 328 void handleError() {
329 AsyncError asyncError = source._error; 329 AsyncError asyncError = source._error;
330 bool matchesTest = true; 330 bool matchesTest = true;
331 if (listener.hasErrorTest) { 331 if (listener.hasErrorTest) {
332 _FutureErrorTest test = listener._errorTest; 332 _FutureErrorTest test = listener._errorTest;
333 try { 333 try {
334 matchesTest = ((__x27) => DEVC$RT.cast(__x27, dynamic, bool, "CastGeneral", """line 499, column 29 of dart:async/future_impl.dart: """, __x27 is bool, true) )(zone.runUnary(test, asyncError.error)); 334 matchesTest = ((__x27) => DEVC$RT.cast(__x27, dynamic, bool, "DynamicCast", """line 499, column 29 of dart:async/future_impl.dart: """, __x27 is bool, true) )(zone.runUnary(test, asyncError.error));
335 } 335 }
336 catch (e, s) { 336 catch (e, s) {
337 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 337 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
338 listenerHasValue = false; 338 listenerHasValue = false;
339 return;} 339 return;}
340 } 340 }
341 Function errorCallback = listener._onError; 341 Function errorCallback = listener._onError;
342 if (matchesTest && errorCallback != null) { 342 if (matchesTest && errorCallback != null) {
343 try { 343 try {
344 if (errorCallback is ZoneBinaryCallback) { 344 if (errorCallback is ZoneBinaryCallback) {
345 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace); 345 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace);
346 } 346 }
347 else { 347 else {
348 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t14, "CastGeneral", """line 515, column 54 of dart:async/future_impl.dart: "" ", errorCallback is __t14, true), asyncError.error); 348 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t14, "ImplicitCast", """line 515, column 54 of dart:async/future_impl.dart: " "", errorCallback is __t14, true), asyncError.error);
349 } 349 }
350 } 350 }
351 catch (e, s) { 351 catch (e, s) {
352 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 352 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
353 listenerHasValue = false; 353 listenerHasValue = false;
354 return;} 354 return;}
355 listenerHasValue = true; 355 listenerHasValue = true;
356 } 356 }
357 else { 357 else {
358 listenerValueOrError = asyncError; 358 listenerValueOrError = asyncError;
(...skipping 21 matching lines...) Expand all
380 completeResult.then((ignored) { 380 completeResult.then((ignored) {
381 _propagateToListeners(source, new _FutureListener.chain(result)); 381 _propagateToListeners(source, new _FutureListener.chain(result));
382 } 382 }
383 , onError: (error, [stackTrace]) { 383 , onError: (error, [stackTrace]) {
384 if (completeResult is! _Future) { 384 if (completeResult is! _Future) {
385 completeResult = new _Future(); 385 completeResult = new _Future();
386 completeResult._setError(error, stackTrace); 386 completeResult._setError(error, stackTrace);
387 } 387 }
388 _propagateToListeners(DEVC$RT.cast(completeResult, dynamic, DEVC$RT.type((_ Future<dynamic> _) { 388 _propagateToListeners(DEVC$RT.cast(completeResult, dynamic, DEVC$RT.type((_ Future<dynamic> _) {
389 } 389 }
390 ), "CastGeneral", """line 559, column 37 of dart:async/future_impl.dart: """ , completeResult is _Future<dynamic>, true), new _FutureListener.chain(result)); 390 ), "DynamicCast", """line 559, column 37 of dart:async/future_impl.dart: """ , completeResult is _Future<dynamic>, true), new _FutureListener.chain(result));
391 } 391 }
392 ); 392 );
393 } 393 }
394 } 394 }
395 if (!hasError) { 395 if (!hasError) {
396 if (listener.handlesValue) { 396 if (listener.handlesValue) {
397 listenerHasValue = handleValueCallback(); 397 listenerHasValue = handleValueCallback();
398 } 398 }
399 } 399 }
400 else { 400 else {
401 handleError(); 401 handleError();
402 } 402 }
403 if (listener.handlesComplete) { 403 if (listener.handlesComplete) {
404 handleWhenCompleteCallback(); 404 handleWhenCompleteCallback();
405 } 405 }
406 if (oldZone != null) Zone._leave(oldZone); 406 if (oldZone != null) Zone._leave(oldZone);
407 if (isPropagationAborted) return; if (listenerHasValue && !identical(sourceValu e, listenerValueOrError) && listenerValueOrError is Future) { 407 if (isPropagationAborted) return; if (listenerHasValue && !identical(sourceValu e, listenerValueOrError) && listenerValueOrError is Future) {
408 Future chainSource = DEVC$RT.cast(listenerValueOrError, dynamic, DEVC$RT.type((F uture<dynamic> _) { 408 Future chainSource = DEVC$RT.cast(listenerValueOrError, dynamic, DEVC$RT.type((F uture<dynamic> _) {
409 } 409 }
410 ), "CastGeneral", """line 585, column 32 of dart:async/future_impl.dart: """, li stenerValueOrError is Future<dynamic>, true); 410 ), "DynamicCast", """line 585, column 32 of dart:async/future_impl.dart: """, li stenerValueOrError is Future<dynamic>, true);
411 _Future result = listener.result; 411 _Future result = listener.result;
412 if (chainSource is _Future) { 412 if (chainSource is _Future) {
413 if (chainSource._isComplete) { 413 if (chainSource._isComplete) {
414 result._isChained = true; 414 result._isChained = true;
415 source = chainSource; 415 source = chainSource;
416 listeners = new _FutureListener.chain(result); 416 listeners = new _FutureListener.chain(result);
417 continue; 417 continue;
418 } 418 }
419 else { 419 else {
420 _chainCoreFuture(chainSource, result); 420 _chainCoreFuture(chainSource, result);
421 } 421 }
422 } 422 }
423 else { 423 else {
424 _chainForeignFuture(chainSource, result); 424 _chainForeignFuture(chainSource, result);
425 } 425 }
426 return;} 426 return;}
427 } 427 }
428 _Future result = listener.result; 428 _Future result = listener.result;
429 listeners = result._removeListeners(); 429 listeners = result._removeListeners();
430 if (listenerHasValue) { 430 if (listenerHasValue) {
431 result._setValue(listenerValueOrError); 431 result._setValue(listenerValueOrError);
432 } 432 }
433 else { 433 else {
434 AsyncError asyncError = DEVC$RT.cast(listenerValueOrError, dynamic, AsyncError, "CastGeneral", """line 610, column 33 of dart:async/future_impl.dart: """, liste nerValueOrError is AsyncError, true); 434 AsyncError asyncError = DEVC$RT.cast(listenerValueOrError, dynamic, AsyncError, "DynamicCast", """line 610, column 33 of dart:async/future_impl.dart: """, liste nerValueOrError is AsyncError, true);
435 result._setErrorObject(asyncError); 435 result._setErrorObject(asyncError);
436 } 436 }
437 source = result; 437 source = result;
438 } 438 }
439 } 439 }
440 Future timeout(Duration timeLimit, { 440 Future timeout(Duration timeLimit, {
441 onTimeout()} 441 onTimeout()}
442 ) { 442 ) {
443 if (_isComplete) return new _Future.immediate(this); 443 if (_isComplete) return new _Future.immediate(this);
444 _Future result = new _Future(); 444 _Future result = new _Future();
(...skipping 19 matching lines...) Expand all
464 } 464 }
465 this.then((T v) { 465 this.then((T v) {
466 if (timer.isActive) { 466 if (timer.isActive) {
467 timer.cancel(); 467 timer.cancel();
468 result._completeWithValue(v); 468 result._completeWithValue(v);
469 } 469 }
470 } 470 }
471 , onError: (e, s) { 471 , onError: (e, s) {
472 if (timer.isActive) { 472 if (timer.isActive) {
473 timer.cancel(); 473 timer.cancel();
474 result._completeError(e, DEVC$RT.cast(s, dynamic, StackTrace, "CastGeneral", "" "line 646, column 34 of dart:async/future_impl.dart: """, s is StackTrace, true) ); 474 result._completeError(e, DEVC$RT.cast(s, dynamic, StackTrace, "DynamicCast", "" "line 646, column 34 of dart:async/future_impl.dart: """, s is StackTrace, true) );
475 } 475 }
476 } 476 }
477 ); 477 );
478 return result; 478 return result;
479 } 479 }
480 } 480 }
481 typedef dynamic __t14(dynamic __u15); 481 typedef dynamic __t14(dynamic __u15);
482 typedef bool __t16(dynamic __u17); 482 typedef bool __t16(dynamic __u17);
483 typedef dynamic __t18(); 483 typedef dynamic __t18();
484 typedef dynamic __t20<T>(T __u21); 484 typedef dynamic __t20<T>(T __u21);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/future.dart ('k') | test/dart_codegen/expect/async/schedule_microtask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698