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

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

Issue 1038213003: Downward inference (Closed) Base URL: git@github.com:dart-lang/dart-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, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t14, true); 61 assert (handlesValue); return DEVC$RT.cast(callback, Function, __t11, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t11, 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, "Composite Cast", """line 117, column 12 of dart:async/future_impl.dart: """, callback is _ _t16, false); 65 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, __t13, "Composite Cast", """line 117, column 12 of dart:async/future_impl.dart: """, callback is _ _t13, false);
66 } 66 }
67 _FutureAction get _whenCompleteAction { 67 _FutureAction get _whenCompleteAction {
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); 68 assert (handlesComplete); return DEVC$RT.cast(callback, Function, __t15, "Implic itCast", """line 121, column 12 of dart:async/future_impl.dart: """, callback is __t15, 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 15 matching lines...) Expand all
94 } 94 }
95 else { 95 else {
96 assert (_isChained); _state = _INCOMPLETE; 96 assert (_isChained); _state = _INCOMPLETE;
97 } 97 }
98 } 98 }
99 Future then(f(T value), { 99 Future then(f(T value), {
100 Function onError} 100 Function onError}
101 ) { 101 ) {
102 _Future result = new _Future(); 102 _Future result = new _Future();
103 if (!identical(result._zone, _ROOT_ZONE)) { 103 if (!identical(result._zone, _ROOT_ZONE)) {
104 f = ((__x22) => DEVC$RT.wrap((dynamic f(dynamic __u19)) { 104 f = ((__x19) => DEVC$RT.wrap((dynamic f(dynamic __u16)) {
105 dynamic c(dynamic x0) => f(x0); 105 dynamic c(dynamic x0) => f(x0);
106 return f == null ? null : c; 106 return f == null ? null : c;
107 } 107 }
108 , __x22, __t14, DEVC$RT.type((__t20<T> _) { 108 , __x19, __t11, DEVC$RT.type((__t17<T> _) {
109 } 109 }
110 ), "Wrap", """line 208, column 11 of dart:async/future_impl.dart: """, __x22 is __t20<T>))(result._zone.registerUnaryCallback(f)); 110 ), "Wrap", """line 208, column 11 of dart:async/future_impl.dart: """, __x19 is __t17<T>))(result._zone.registerUnaryCallback(f));
111 if (onError != null) { 111 if (onError != null) {
112 onError = _registerErrorHandler(onError, result._zone); 112 onError = _registerErrorHandler(onError, result._zone);
113 } 113 }
114 } 114 }
115 _addListener(new _FutureListener.then(result, f, onError)); 115 _addListener(new _FutureListener.then(result, f, onError));
116 return result; 116 return result;
117 } 117 }
118 Future catchError(Function onError, { 118 Future catchError(Function onError, {
119 bool test(error)} 119 bool test(error)}
120 ) { 120 ) {
121 _Future result = new _Future(); 121 _Future result = new _Future();
122 if (!identical(result._zone, _ROOT_ZONE)) { 122 if (!identical(result._zone, _ROOT_ZONE)) {
123 onError = _registerErrorHandler(onError, result._zone); 123 onError = _registerErrorHandler(onError, result._zone);
124 if (test != null) test = ((__x25) => DEVC$RT.wrap((dynamic f(dynamic __u24)) { 124 if (test != null) test = ((__x22) => DEVC$RT.wrap((dynamic f(dynamic __u21)) {
125 dynamic c(dynamic x0) => ((__x23) => DEVC$RT.cast(__x23, dynamic, bool, "CastRes ult", """line 221, column 32 of dart:async/future_impl.dart: """, __x23 is bool, true))(f(x0)); 125 dynamic c(dynamic x0) => ((__x20) => DEVC$RT.cast(__x20, dynamic, bool, "CastRes ult", """line 221, column 32 of dart:async/future_impl.dart: """, __x20 is bool, true))(f(x0));
126 return f == null ? null : c; 126 return f == null ? null : c;
127 } 127 }
128 , __x25, __t14, __t16, "Wrap", """line 221, column 32 of dart:async/future_impl. dart: """, __x25 is __t16))(result._zone.registerUnaryCallback(test)); 128 , __x22, __t11, __t13, "Wrap", """line 221, column 32 of dart:async/future_impl. dart: """, __x22 is __t13))(result._zone.registerUnaryCallback(test));
129 } 129 }
130 _addListener(new _FutureListener.catchError(result, onError, test)); 130 _addListener(new _FutureListener.catchError(result, onError, test));
131 return result; 131 return result;
132 } 132 }
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 ), "CompositeCast", """line 233, column 12 of dart:async/future_impl.dart: """, result 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() => new Stream<T>.fromFuture(this);
146 }
147 ), DEVC$RT.type((Stream<T> _) {
148 }
149 ), "InferableAllocation", """line 236, column 27 of dart:async/future_impl.dart: """, __x26 is Stream<T>, false))(new Stream.fromFuture(this));
150 void _markPendingCompletion() { 146 void _markPendingCompletion() {
151 if (!_mayComplete) throw new StateError("Future already completed"); 147 if (!_mayComplete) throw new StateError("Future already completed");
152 _state = _PENDING_COMPLETE; 148 _state = _PENDING_COMPLETE;
153 } 149 }
154 T get _value { 150 T get _value {
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); 151 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 } 152 }
157 AsyncError get _error { 153 AsyncError get _error {
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); 154 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 } 155 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 listenerValueOrError = new AsyncError(e, s); 320 listenerValueOrError = new AsyncError(e, s);
325 return false; 321 return false;
326 } 322 }
327 } 323 }
328 void handleError() { 324 void handleError() {
329 AsyncError asyncError = source._error; 325 AsyncError asyncError = source._error;
330 bool matchesTest = true; 326 bool matchesTest = true;
331 if (listener.hasErrorTest) { 327 if (listener.hasErrorTest) {
332 _FutureErrorTest test = listener._errorTest; 328 _FutureErrorTest test = listener._errorTest;
333 try { 329 try {
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)); 330 matchesTest = ((__x23) => DEVC$RT.cast(__x23, dynamic, bool, "DynamicCast", """line 499, column 29 of dart:async/future_impl.dart: """, __x23 is bool, true) )(zone.runUnary(test, asyncError.error));
335 } 331 }
336 catch (e, s) { 332 catch (e, s) {
337 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 333 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
338 listenerHasValue = false; 334 listenerHasValue = false;
339 return;} 335 return;}
340 } 336 }
341 Function errorCallback = listener._onError; 337 Function errorCallback = listener._onError;
342 if (matchesTest && errorCallback != null) { 338 if (matchesTest && errorCallback != null) {
343 try { 339 try {
344 if (errorCallback is ZoneBinaryCallback) { 340 if (errorCallback is ZoneBinaryCallback) {
345 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace); 341 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace);
346 } 342 }
347 else { 343 else {
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); 344 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t11, "ImplicitCast", """line 515, column 54 of dart:async/future_impl.dart: " "", errorCallback is __t11, true), asyncError.error);
349 } 345 }
350 } 346 }
351 catch (e, s) { 347 catch (e, s) {
352 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 348 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
353 listenerHasValue = false; 349 listenerHasValue = false;
354 return;} 350 return;}
355 listenerHasValue = true; 351 listenerHasValue = true;
356 } 352 }
357 else { 353 else {
358 listenerValueOrError = asyncError; 354 listenerValueOrError = asyncError;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 , onError: (e, s) { 467 , onError: (e, s) {
472 if (timer.isActive) { 468 if (timer.isActive) {
473 timer.cancel(); 469 timer.cancel();
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) ); 470 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 } 471 }
476 } 472 }
477 ); 473 );
478 return result; 474 return result;
479 } 475 }
480 } 476 }
481 typedef dynamic __t14(dynamic __u15); 477 typedef dynamic __t11(dynamic __u12);
482 typedef bool __t16(dynamic __u17); 478 typedef bool __t13(dynamic __u14);
483 typedef dynamic __t18(); 479 typedef dynamic __t15();
484 typedef dynamic __t20<T>(T __u21); 480 typedef dynamic __t17<T>(T __u18);
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