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

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

Issue 1038583004: Rationalize coercions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 9 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 abstract class Future<T> {static final _Future _nullFuture = ((__x10) => DEVC$R T.cast(__x10, DEVC$RT.type((Future<dynamic> _) { 2 abstract class Future<T> {static final _Future _nullFuture = ((__x10) => DEVC$R T.cast(__x10, DEVC$RT.type((Future<dynamic> _) {
3 } 3 }
4 ), DEVC$RT.type((_Future<dynamic> _) { 4 ), DEVC$RT.type((_Future<dynamic> _) {
5 } 5 }
6 ), "CastExact", """line 98, column 38 of dart:async/future.dart: """, __x10 is _ Future<dynamic>, true))(new Future.value(null)); 6 ), "InferableAllocation", """line 98, column 38 of dart:async/future.dart: """, __x10 is _Future<dynamic>, true))(new Future.value(null));
7 factory Future(computation()) { 7 factory Future(computation()) {
8 _Future result = new _Future<T>(); 8 _Future result = new _Future<T>();
9 Timer.run(() { 9 Timer.run(() {
10 try { 10 try {
11 result._complete(computation()); 11 result._complete(computation());
12 } 12 }
13 catch (e, s) { 13 catch (e, s) {
14 _completeWithErrorCallback(result, e, s); 14 _completeWithErrorCallback(result, e, s);
15 } 15 }
16 } 16 }
17 ); 17 );
18 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) { 18 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) {
19 } 19 }
20 ), DEVC$RT.type((Future<T> _) { 20 ), DEVC$RT.type((Future<T> _) {
21 } 21 }
22 ), "CastDynamic", """line 123, column 12 of dart:async/future.dart: """, resul t is Future<T>, false); 22 ), "CompositeCast", """line 123, column 12 of dart:async/future.dart: """, res ult is Future<T>, false);
23 } 23 }
24 factory Future.microtask(computation()) { 24 factory Future.microtask(computation()) {
25 _Future result = new _Future<T>(); 25 _Future result = new _Future<T>();
26 scheduleMicrotask(() { 26 scheduleMicrotask(() {
27 try { 27 try {
28 result._complete(computation()); 28 result._complete(computation());
29 } 29 }
30 catch (e, s) { 30 catch (e, s) {
31 _completeWithErrorCallback(result, e, s); 31 _completeWithErrorCallback(result, e, s);
32 } 32 }
33 } 33 }
34 ); 34 );
35 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) { 35 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) {
36 } 36 }
37 ), DEVC$RT.type((Future<T> _) { 37 ), DEVC$RT.type((Future<T> _) {
38 } 38 }
39 ), "CastDynamic", """line 149, column 12 of dart:async/future.dart: """, resul t is Future<T>, false); 39 ), "CompositeCast", """line 149, column 12 of dart:async/future.dart: """, res ult is Future<T>, false);
40 } 40 }
41 factory Future.sync(computation()) { 41 factory Future.sync(computation()) {
42 try { 42 try {
43 var result = computation(); 43 var result = computation();
44 return new Future<T>.value(result); 44 return new Future<T>.value(result);
45 } 45 }
46 catch (error, stackTrace) { 46 catch (error, stackTrace) {
47 return new Future<T>.error(error, stackTrace); 47 return new Future<T>.error(error, stackTrace);
48 } 48 }
49 } 49 }
(...skipping 19 matching lines...) Expand all
69 } 69 }
70 catch (e, s) { 70 catch (e, s) {
71 _completeWithErrorCallback(result, e, s); 71 _completeWithErrorCallback(result, e, s);
72 } 72 }
73 } 73 }
74 ); 74 );
75 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) { 75 return DEVC$RT.cast(result, DEVC$RT.type((_Future<dynamic> _) {
76 } 76 }
77 ), DEVC$RT.type((Future<T> _) { 77 ), DEVC$RT.type((Future<T> _) {
78 } 78 }
79 ), "CastDynamic", """line 233, column 12 of dart:async/future.dart: """, resul t is Future<T>, false); 79 ), "CompositeCast", """line 233, column 12 of dart:async/future.dart: """, res ult is Future<T>, false);
80 } 80 }
81 static Future<List> wait(Iterable<Future> futures, { 81 static Future<List> wait(Iterable<Future> futures, {
82 bool eagerError : false, void cleanUp(successValue)} 82 bool eagerError : false, void cleanUp(successValue)}
83 ) { 83 ) {
84 final _Future<List> result = new _Future<List>(); 84 final _Future<List> result = new _Future<List>();
85 List values; 85 List values;
86 int remaining = 0; 86 int remaining = 0;
87 var error; 87 var error;
88 StackTrace stackTrace; 88 StackTrace stackTrace;
89 void handleError(theError, theStackTrace) { 89 void handleError(theError, theStackTrace) {
90 remaining--; 90 remaining--;
91 if (values != null) { 91 if (values != null) {
92 if (cleanUp != null) { 92 if (cleanUp != null) {
93 for (var value in values) { 93 for (var value in values) {
94 if (value != null) { 94 if (value != null) {
95 new Future.sync(() { 95 new Future.sync(() {
96 cleanUp(value); 96 cleanUp(value);
97 } 97 }
98 ); 98 );
99 } 99 }
100 } 100 }
101 } 101 }
102 values = null; 102 values = null;
103 if (remaining == 0 || eagerError) { 103 if (remaining == 0 || eagerError) {
104 result._completeError(theError, DEVC$RT.cast(theStackTrace, dynamic, Sta ckTrace, "CastGeneral", """line 280, column 43 of dart:async/future.dart: """, t heStackTrace is StackTrace, true)); 104 result._completeError(theError, DEVC$RT.cast(theStackTrace, dynamic, Sta ckTrace, "DynamicCast", """line 280, column 43 of dart:async/future.dart: """, t heStackTrace is StackTrace, true));
105 } 105 }
106 else { 106 else {
107 error = theError; 107 error = theError;
108 stackTrace = DEVC$RT.cast(theStackTrace, dynamic, StackTrace, "CastGene ral", """line 283, column 24 of dart:async/future.dart: """, theStackTrace is St ackTrace, true); 108 stackTrace = DEVC$RT.cast(theStackTrace, dynamic, StackTrace, "DynamicC ast", """line 283, column 24 of dart:async/future.dart: """, theStackTrace is St ackTrace, true);
109 } 109 }
110 } 110 }
111 else if (remaining == 0 && !eagerError) { 111 else if (remaining == 0 && !eagerError) {
112 result._completeError(error, stackTrace); 112 result._completeError(error, stackTrace);
113 } 113 }
114 } 114 }
115 for (Future future in futures) { 115 for (Future future in futures) {
116 int pos = remaining++; 116 int pos = remaining++;
117 future.then((Object value) { 117 future.then((Object value) {
118 remaining--; 118 remaining--;
(...skipping 15 matching lines...) Expand all
134 } 134 }
135 } 135 }
136 } 136 }
137 , onError: handleError); 137 , onError: handleError);
138 } 138 }
139 if (remaining == 0) { 139 if (remaining == 0) {
140 return ((__x11) => DEVC$RT.cast(__x11, DEVC$RT.type((Future<dynamic> _) { 140 return ((__x11) => DEVC$RT.cast(__x11, DEVC$RT.type((Future<dynamic> _) {
141 } 141 }
142 ), DEVC$RT.type((Future<List<dynamic>> _) { 142 ), DEVC$RT.type((Future<List<dynamic>> _) {
143 } 143 }
144 ), "CastExact", """line 313, column 14 of dart:async/future.dart: """, __x11 is Future<List<dynamic>>, false))(new Future.value(const [])); 144 ), "InferableAllocation", """line 313, column 14 of dart:async/future.dart: """, __x11 is Future<List<dynamic>>, false))(new Future.value(const []));
145 } 145 }
146 values = new List(remaining); 146 values = new List(remaining);
147 return result; 147 return result;
148 } 148 }
149 static Future forEach(Iterable input, f(element)) { 149 static Future forEach(Iterable input, f(element)) {
150 Iterator iterator = input.iterator; 150 Iterator iterator = input.iterator;
151 return doWhile(() { 151 return doWhile(() {
152 if (!iterator.moveNext()) return false; 152 if (!iterator.moveNext()) return false;
153 return new Future.sync(() => f(iterator.current)).then((_) => true); 153 return new Future.sync(() => f(iterator.current)).then((_) => true);
154 } 154 }
155 ); 155 );
156 } 156 }
157 static Future doWhile(f()) { 157 static Future doWhile(f()) {
158 _Future doneSignal = new _Future(); 158 _Future doneSignal = new _Future();
159 var nextIteration; 159 var nextIteration;
160 nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) { 160 nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) {
161 if (keepGoing) { 161 if (keepGoing) {
162 new Future.sync(f).then(DEVC$RT.cast(nextIteration, dynamic, __t12, "CastG eneral", """line 361, column 33 of dart:async/future.dart: """, nextIteration is __t12, true), onError: doneSignal._completeError); 162 new Future.sync(f).then(DEVC$RT.cast(nextIteration, dynamic, __t12, "Dynam icCast", """line 361, column 33 of dart:async/future.dart: """, nextIteration is __t12, true), onError: doneSignal._completeError);
163 } 163 }
164 else { 164 else {
165 doneSignal._complete(null); 165 doneSignal._complete(null);
166 } 166 }
167 } 167 }
168 , runGuarded: true); 168 , runGuarded: true);
169 nextIteration(true); 169 nextIteration(true);
170 return doneSignal; 170 return doneSignal;
171 } 171 }
172 Future then(onValue(T value), { 172 Future then(onValue(T value), {
(...skipping 19 matching lines...) Expand all
192 } 192 }
193 } 193 }
194 abstract class Completer<T> {factory Completer() => new _AsyncCompleter<T>(); 194 abstract class Completer<T> {factory Completer() => new _AsyncCompleter<T>();
195 factory Completer.sync() => new _SyncCompleter<T>(); 195 factory Completer.sync() => new _SyncCompleter<T>();
196 Future<T> get future; 196 Future<T> get future;
197 void complete([value]); 197 void complete([value]);
198 void completeError(Object error, [StackTrace stackTrace]); 198 void completeError(Object error, [StackTrace stackTrace]);
199 bool get isCompleted; 199 bool get isCompleted;
200 } 200 }
201 void _completeWithErrorCallback(_Future result, error, stackTrace) { 201 void _completeWithErrorCallback(_Future result, error, stackTrace) {
202 AsyncError replacement = Zone.current.errorCallback(error, DEVC$RT.cast(stackTra ce, dynamic, StackTrace, "CastGeneral", """line 719, column 62 of dart:async/fut ure.dart: """, stackTrace is StackTrace, true)); 202 AsyncError replacement = Zone.current.errorCallback(error, DEVC$RT.cast(stackTra ce, dynamic, StackTrace, "DynamicCast", """line 719, column 62 of dart:async/fut ure.dart: """, stackTrace is StackTrace, true));
203 if (replacement != null) { 203 if (replacement != null) {
204 error = _nonNullError(replacement.error); 204 error = _nonNullError(replacement.error);
205 stackTrace = replacement.stackTrace; 205 stackTrace = replacement.stackTrace;
206 } 206 }
207 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Cas tGeneral", """line 724, column 32 of dart:async/future.dart: """, stackTrace is StackTrace, true)); 207 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Dyn amicCast", """line 724, column 32 of dart:async/future.dart: """, stackTrace is StackTrace, true));
208 } 208 }
209 Object _nonNullError(Object error) => (error != null) ? error : new NullThrownE rror(); 209 Object _nonNullError(Object error) => (error != null) ? error : new NullThrownE rror();
210 typedef dynamic __t12(dynamic __u13); 210 typedef dynamic __t12(dynamic __u13);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/broadcast_stream_controller.dart ('k') | test/dart_codegen/expect/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698