| OLD | NEW |
| 1 part of dart.async; | 1 part of dart.async; |
| 2 | 2 abstract class Future<T> {static final _Future _nullFuture = ((__x10) => DDC$RT
.cast(__x10, DDC$RT.type((Future<dynamic> _) { |
| 3 abstract class Future<T> { | 3 } |
| 4 static final _Future _nullFuture = ((__x10) => DDC$RT.cast(__x10, | 4 ), DDC$RT.type((_Future<dynamic> _) { |
| 5 DDC$RT.type((Future<dynamic> _) {}), DDC$RT.type((_Future<dynamic> _) {}), | 5 } |
| 6 "CastExact", """line 98, column 38 of dart:async/future.dart: """, | 6 ), "CastExact", """line 98, column 38 of dart:async/future.dart: """, __x10 is _
Future<dynamic>, true))(new Future.value(null)); |
| 7 __x10 is _Future<dynamic>, true))(new Future.value(null)); | 7 factory Future(computation()) { |
| 8 factory Future(computation()) { | 8 _Future result = new _Future<T>(); |
| 9 _Future result = new _Future<T>(); | 9 Timer.run(() { |
| 10 Timer.run(() { | |
| 11 try { | |
| 12 result._complete(computation()); | |
| 13 } catch (e, s) { | |
| 14 _completeWithErrorCallback(result, e, s); | |
| 15 } | |
| 16 }); | |
| 17 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) {}), | |
| 18 DDC$RT.type((Future<T> _) {}), "CastDynamic", | |
| 19 """line 123, column 12 of dart:async/future.dart: """, | |
| 20 result is Future<T>, false); | |
| 21 } | |
| 22 factory Future.microtask(computation()) { | |
| 23 _Future result = new _Future<T>(); | |
| 24 scheduleMicrotask(() { | |
| 25 try { | |
| 26 result._complete(computation()); | |
| 27 } catch (e, s) { | |
| 28 _completeWithErrorCallback(result, e, s); | |
| 29 } | |
| 30 }); | |
| 31 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) {}), | |
| 32 DDC$RT.type((Future<T> _) {}), "CastDynamic", | |
| 33 """line 149, column 12 of dart:async/future.dart: """, | |
| 34 result is Future<T>, false); | |
| 35 } | |
| 36 factory Future.sync(computation()) { | |
| 37 try { | 10 try { |
| 38 var result = computation(); | 11 result._complete(computation()); |
| 39 return new Future<T>.value(result); | 12 } |
| 40 } catch (error, stackTrace) { | 13 catch (e, s) { |
| 41 return new Future<T>.error(error, stackTrace); | 14 _completeWithErrorCallback(result, e, s); |
| 42 } | 15 } |
| 43 } | 16 } |
| 44 factory Future.value([value]) { | 17 ); |
| 45 return new _Future<T>.immediate(value); | 18 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) { |
| 46 } | 19 } |
| 47 factory Future.error(Object error, [StackTrace stackTrace]) { | 20 ), DDC$RT.type((Future<T> _) { |
| 48 error = _nonNullError(error); | 21 } |
| 49 if (!identical(Zone.current, _ROOT_ZONE)) { | 22 ), "CastDynamic", """line 123, column 12 of dart:async/future.dart: """, resul
t is Future<T>, false); |
| 50 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); | 23 } |
| 51 if (replacement != null) { | 24 factory Future.microtask(computation()) { |
| 52 error = _nonNullError(replacement.error); | 25 _Future result = new _Future<T>(); |
| 53 stackTrace = replacement.stackTrace; | 26 scheduleMicrotask(() { |
| 54 } | 27 try { |
| 55 } | 28 result._complete(computation()); |
| 56 return new _Future<T>.immediateError(error, stackTrace); | 29 } |
| 57 } | 30 catch (e, s) { |
| 58 factory Future.delayed(Duration duration, [T computation()]) { | 31 _completeWithErrorCallback(result, e, s); |
| 59 _Future result = new _Future<T>(); | 32 } |
| 60 new Timer(duration, () { | 33 } |
| 61 try { | 34 ); |
| 62 result._complete(computation == null ? null : computation()); | 35 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) { |
| 63 } catch (e, s) { | 36 } |
| 64 _completeWithErrorCallback(result, e, s); | 37 ), DDC$RT.type((Future<T> _) { |
| 65 } | 38 } |
| 66 }); | 39 ), "CastDynamic", """line 149, column 12 of dart:async/future.dart: """, resul
t is Future<T>, false); |
| 67 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) {}), | 40 } |
| 68 DDC$RT.type((Future<T> _) {}), "CastDynamic", | 41 factory Future.sync(computation()) { |
| 69 """line 233, column 12 of dart:async/future.dart: """, | 42 try { |
| 70 result is Future<T>, false); | 43 var result = computation(); |
| 71 } | 44 return new Future<T>.value(result); |
| 72 static Future<List> wait(Iterable<Future> futures, | 45 } |
| 73 {bool eagerError: false, void cleanUp(successValue)}) { | 46 catch (error, stackTrace) { |
| 74 final _Future<List> result = new _Future<List>(); | 47 return new Future<T>.error(error, stackTrace); |
| 75 List values; | 48 } |
| 76 int remaining = 0; | 49 } |
| 77 var error; | 50 factory Future.value([value]) { |
| 78 StackTrace stackTrace; | 51 return new _Future<T>.immediate(value); |
| 79 void handleError(theError, theStackTrace) { | 52 } |
| 80 remaining--; | 53 factory Future.error(Object error, [StackTrace stackTrace]) { |
| 81 if (values != null) { | 54 error = _nonNullError(error); |
| 82 if (cleanUp != null) { | 55 if (!identical(Zone.current, _ROOT_ZONE)) { |
| 83 for (var value in values) { | 56 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
| 84 if (value != null) { | 57 if (replacement != null) { |
| 85 new Future.sync(() { | 58 error = _nonNullError(replacement.error); |
| 86 cleanUp(value); | 59 stackTrace = replacement.stackTrace; |
| 87 }); | 60 } |
| 88 } | 61 } |
| 89 } | 62 return new _Future<T>.immediateError(error, stackTrace); |
| 90 } | 63 } |
| 91 values = null; | 64 factory Future.delayed(Duration duration, [T computation()]) { |
| 92 if (remaining == 0 || eagerError) { | 65 _Future result = new _Future<T>(); |
| 93 result._completeError(theError, DDC$RT.cast(theStackTrace, dynamic, | 66 new Timer(duration, () { |
| 94 StackTrace, "CastGeneral", | 67 try { |
| 95 """line 280, column 43 of dart:async/future.dart: """, | 68 result._complete(computation == null ? null : computation()); |
| 96 theStackTrace is StackTrace, true)); | 69 } |
| 97 } else { | 70 catch (e, s) { |
| 98 error = theError; | 71 _completeWithErrorCallback(result, e, s); |
| 99 stackTrace = DDC$RT.cast(theStackTrace, dynamic, StackTrace, | 72 } |
| 100 "CastGeneral", | 73 } |
| 101 """line 283, column 24 of dart:async/future.dart: """, | 74 ); |
| 102 theStackTrace is StackTrace, true); | 75 return DDC$RT.cast(result, DDC$RT.type((_Future<dynamic> _) { |
| 103 } | 76 } |
| 104 } else if (remaining == 0 && !eagerError) { | 77 ), DDC$RT.type((Future<T> _) { |
| 105 result._completeError(error, stackTrace); | 78 } |
| 106 } | 79 ), "CastDynamic", """line 233, column 12 of dart:async/future.dart: """, resul
t is Future<T>, false); |
| 107 } | 80 } |
| 108 for (Future future in futures) { | 81 static Future<List> wait(Iterable<Future> futures, { |
| 109 int pos = remaining++; | 82 bool eagerError : false, void cleanUp(successValue)} |
| 110 future.then(((__x16) => DDC$RT.wrap((dynamic f(Object __u11)) { | 83 ) { |
| 111 dynamic c(Object x0) => f(x0); | 84 final _Future<List> result = new _Future<List>(); |
| 112 return f == null ? null : c; | 85 List values; |
| 113 }, __x16, __t14, __t12, "WrapLiteral", | 86 int remaining = 0; |
| 114 """line 294, column 19 of dart:async/future.dart: """, | 87 var error; |
| 115 __x16 is __t12))((Object value) { | 88 StackTrace stackTrace; |
| 116 remaining--; | 89 void handleError(theError, theStackTrace) { |
| 117 if (values != null) { | 90 remaining--; |
| 118 values[pos] = value; | 91 if (values != null) { |
| 119 if (remaining == 0) { | 92 if (cleanUp != null) { |
| 120 result._completeWithValue(values); | 93 for (var value in values) { |
| 121 } | 94 if (value != null) { |
| 122 } else { | |
| 123 if (cleanUp != null && value != null) { | |
| 124 new Future.sync(() { | 95 new Future.sync(() { |
| 125 cleanUp(value); | 96 cleanUp(value); |
| 126 }); | 97 } |
| 127 } | 98 ); |
| 128 if (remaining == 0 && !eagerError) { | 99 } |
| 129 result._completeError(error, stackTrace); | 100 } |
| 130 } | 101 } |
| 131 } | 102 values = null; |
| 132 }), onError: handleError); | 103 if (remaining == 0 || eagerError) { |
| 133 } | 104 result._completeError(theError, DDC$RT.cast(theStackTrace, dynamic, Stac
kTrace, "CastGeneral", """line 280, column 43 of dart:async/future.dart: """, th
eStackTrace is StackTrace, true)); |
| 134 if (remaining == 0) { | 105 } |
| 135 return ((__x17) => DDC$RT.cast(__x17, DDC$RT.type((Future<dynamic> _) {}), | 106 else { |
| 136 DDC$RT.type((Future<List<dynamic>> _) {}), "CastExact", | 107 error = theError; |
| 137 """line 313, column 14 of dart:async/future.dart: """, | 108 stackTrace = DDC$RT.cast(theStackTrace, dynamic, StackTrace, "CastGener
al", """line 283, column 24 of dart:async/future.dart: """, theStackTrace is Sta
ckTrace, true); |
| 138 __x17 is Future<List<dynamic>>, false))(new Future.value(const [])); | 109 } |
| 139 } | 110 } |
| 140 values = new List(remaining); | 111 else if (remaining == 0 && !eagerError) { |
| 141 return result; | 112 result._completeError(error, stackTrace); |
| 142 } | 113 } |
| 143 static Future forEach(Iterable input, f(element)) { | 114 } |
| 144 Iterator iterator = input.iterator; | 115 for (Future future in futures) { |
| 145 return doWhile(() { | 116 int pos = remaining++; |
| 146 if (!iterator.moveNext()) return false; | 117 future.then(((__x16) => DDC$RT.wrap((dynamic f(Object __u11)) { |
| 147 return new Future.sync(() => f(iterator.current)).then((_) => true); | 118 dynamic c(Object x0) => f(x0); |
| 148 }); | 119 return f == null ? null : c; |
| 149 } | 120 } |
| 150 static Future doWhile(f()) { | 121 , __x16, __t14, __t12, "WrapLiteral", """line 294, column 19 of dart:async/f
uture.dart: """, __x16 is __t12))((Object value) { |
| 151 _Future doneSignal = new _Future(); | 122 remaining--; |
| 152 var nextIteration; | 123 if (values != null) { |
| 153 nextIteration = Zone.current.bindUnaryCallback(((__x21) => DDC$RT.wrap( | 124 values[pos] = value; |
| 154 (dynamic f(bool __u18)) { | 125 if (remaining == 0) { |
| 155 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", | 126 result._completeWithValue(values); |
| 156 """line 359, column 52 of dart:async/future.dart: """, x0 is bool, | 127 } |
| 157 true)); | 128 } |
| 158 return f == null ? null : c; | 129 else { |
| 159 }, __x21, __t19, __t12, "WrapLiteral", | 130 if (cleanUp != null && value != null) { |
| 160 """line 359, column 52 of dart:async/future.dart: """, | 131 new Future.sync(() { |
| 161 __x21 is __t12))((bool keepGoing) { | 132 cleanUp(value); |
| 162 if (keepGoing) { | 133 } |
| 163 new Future.sync(f).then(DDC$RT.cast(nextIteration, dynamic, __t12, | 134 ); |
| 164 "CastGeneral", | 135 } |
| 165 """line 361, column 33 of dart:async/future.dart: """, | 136 if (remaining == 0 && !eagerError) { |
| 166 nextIteration is __t12, false), onError: doneSignal._completeError); | 137 result._completeError(error, stackTrace); |
| 167 } else { | 138 } |
| 168 doneSignal._complete(null); | 139 } |
| 169 } | 140 } |
| 170 }), runGuarded: true); | 141 ), onError: handleError); |
| 171 nextIteration(true); | 142 } |
| 172 return doneSignal; | 143 if (remaining == 0) { |
| 173 } | 144 return ((__x17) => DDC$RT.cast(__x17, DDC$RT.type((Future<dynamic> _) { |
| 174 Future then(onValue(T value), {Function onError}); | 145 } |
| 175 Future catchError(Function onError, {bool test(Object error)}); | 146 ), DDC$RT.type((Future<List<dynamic>> _) { |
| 176 Future<T> whenComplete(action()); | 147 } |
| 177 Stream<T> asStream(); | 148 ), "CastExact", """line 313, column 14 of dart:async/future.dart: """, __x17
is Future<List<dynamic>>, false))(new Future.value(const [])); |
| 178 Future timeout(Duration timeLimit, {onTimeout()}); | 149 } |
| 179 } | 150 values = new List(remaining); |
| 180 class TimeoutException implements Exception { | 151 return result; |
| 181 final String message; | 152 } |
| 182 final Duration duration; | 153 static Future forEach(Iterable input, f(element)) { |
| 183 TimeoutException(this.message, [this.duration]); | 154 Iterator iterator = input.iterator; |
| 184 String toString() { | 155 return doWhile(() { |
| 185 String result = "TimeoutException"; | 156 if (!iterator.moveNext()) return false; |
| 186 if (duration != null) result = "TimeoutException after $duration"; | 157 return new Future.sync(() => f(iterator.current)).then((_) => true); |
| 187 if (message != null) result = "$result: $message"; | 158 } |
| 188 return result; | 159 ); |
| 189 } | 160 } |
| 190 } | 161 static Future doWhile(f()) { |
| 191 abstract class Completer<T> { | 162 _Future doneSignal = new _Future(); |
| 192 factory Completer() => new _AsyncCompleter<T>(); | 163 var nextIteration; |
| 193 factory Completer.sync() => new _SyncCompleter<T>(); | 164 nextIteration = Zone.current.bindUnaryCallback(((__x21) => DDC$RT.wrap((dynam
ic f(bool __u18)) { |
| 194 Future<T> get future; | 165 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """line
359, column 52 of dart:async/future.dart: """, x0 is bool, true)); |
| 195 void complete([value]); | 166 return f == null ? null : c; |
| 196 void completeError(Object error, [StackTrace stackTrace]); | 167 } |
| 197 bool get isCompleted; | 168 , __x21, __t19, __t12, "WrapLiteral", """line 359, column 52 of dart:async/fut
ure.dart: """, __x21 is __t12))((bool keepGoing) { |
| 198 } | 169 if (keepGoing) { |
| 199 void _completeWithErrorCallback(_Future result, error, stackTrace) { | 170 new Future.sync(f).then(DDC$RT.cast(nextIteration, dynamic, __t12, "CastGe
neral", """line 361, column 33 of dart:async/future.dart: """, nextIteration is
__t12, false), onError: doneSignal._completeError); |
| 200 AsyncError replacement = Zone.current.errorCallback(error, DDC$RT.cast( | 171 } |
| 201 stackTrace, dynamic, StackTrace, "CastGeneral", | 172 else { |
| 202 """line 719, column 62 of dart:async/future.dart: """, | 173 doneSignal._complete(null); |
| 203 stackTrace is StackTrace, true)); | 174 } |
| 204 if (replacement != null) { | 175 } |
| 205 error = _nonNullError(replacement.error); | 176 ), runGuarded: true); |
| 206 stackTrace = replacement.stackTrace; | 177 nextIteration(true); |
| 207 } | 178 return doneSignal; |
| 208 result._completeError(error, DDC$RT.cast(stackTrace, dynamic, StackTrace, | 179 } |
| 209 "CastGeneral", """line 724, column 32 of dart:async/future.dart: """, | 180 Future then(onValue(T value), { |
| 210 stackTrace is StackTrace, true)); | 181 Function onError} |
| 211 } | 182 ); |
| 212 Object _nonNullError(Object error) => | 183 Future catchError(Function onError, { |
| 213 (error != null) ? error : new NullThrownError(); | 184 bool test(Object error)} |
| 214 typedef dynamic __t12(dynamic __u13); | 185 ); |
| 215 typedef dynamic __t14(Object __u15); | 186 Future<T> whenComplete(action()); |
| 216 typedef dynamic __t19(bool __u20); | 187 Stream<T> asStream(); |
| 188 Future timeout(Duration timeLimit, { |
| 189 onTimeout()} |
| 190 ); |
| 191 } |
| 192 class TimeoutException implements Exception {final String message; |
| 193 final Duration duration; |
| 194 TimeoutException(this.message, [this.duration]); |
| 195 String toString() { |
| 196 String result = "TimeoutException"; |
| 197 if (duration != null) result = "TimeoutException after $duration"; |
| 198 if (message != null) result = "$result: $message"; |
| 199 return result; |
| 200 } |
| 201 } |
| 202 abstract class Completer<T> {factory Completer() => new _AsyncCompleter<T>(); |
| 203 factory Completer.sync() => new _SyncCompleter<T>(); |
| 204 Future<T> get future; |
| 205 void complete([value]); |
| 206 void completeError(Object error, [StackTrace stackTrace]); |
| 207 bool get isCompleted; |
| 208 } |
| 209 void _completeWithErrorCallback(_Future result, error, stackTrace) { |
| 210 AsyncError replacement = Zone.current.errorCallback(error, DDC$RT.cast(stackTrac
e, dynamic, StackTrace, "CastGeneral", """line 719, column 62 of dart:async/futu
re.dart: """, stackTrace is StackTrace, true)); |
| 211 if (replacement != null) { |
| 212 error = _nonNullError(replacement.error); |
| 213 stackTrace = replacement.stackTrace; |
| 214 } |
| 215 result._completeError(error, DDC$RT.cast(stackTrace, dynamic, StackTrace, "Cast
General", """line 724, column 32 of dart:async/future.dart: """, stackTrace is S
tackTrace, true)); |
| 216 } |
| 217 Object _nonNullError(Object error) => (error != null) ? error : new NullThrownE
rror(); |
| 218 typedef dynamic __t12(dynamic __u13); |
| 219 typedef dynamic __t14(Object __u15); |
| 220 typedef dynamic __t19(bool __u20); |
| OLD | NEW |