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

Side by Side Diff: test/dart_codegen/expect/async/stream.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 Stream<T> {Stream(); 2 abstract class Stream<T> {Stream();
3 factory Stream.fromFuture(Future<T> future) { 3 factory Stream.fromFuture(Future<T> future) {
4 _StreamController<T> controller = ((__x29) => DEVC$RT.cast(__x29, DEVC$RT.type ((StreamController<T> _) { 4 _StreamController<T> controller = ((__x29) => DEVC$RT.cast(__x29, DEVC$RT.type ((StreamController<T> _) {
5 } 5 }
6 ), DEVC$RT.type((_StreamController<T> _) { 6 ), DEVC$RT.type((_StreamController<T> _) {
7 } 7 }
8 ), "CastExact", """line 87, column 39 of dart:async/stream.dart: """, __x29 is _StreamController<T>, false))(new StreamController<T>(sync: true)); 8 ), "InferableAllocation", """line 87, column 39 of dart:async/stream.dart: """ , __x29 is _StreamController<T>, false))(new StreamController<T>(sync: true));
9 future.then(((__x35) => DEVC$RT.wrap((dynamic f(dynamic __u30)) { 9 future.then(((__x35) => DEVC$RT.wrap((dynamic f(dynamic __u30)) {
10 dynamic c(dynamic x0) => f(x0); 10 dynamic c(dynamic x0) => f(x0);
11 return f == null ? null : c; 11 return f == null ? null : c;
12 } 12 }
13 , __x35, __t33, DEVC$RT.type((__t31<T> _) { 13 , __x35, __t33, DEVC$RT.type((__t31<T> _) {
14 } 14 }
15 ), "WrapLiteral", """line 88, column 17 of dart:async/stream.dart: """, __x35 is __t31<T>))((value) { 15 ), "WrapLiteral", """line 88, column 17 of dart:async/stream.dart: """, __x35 is __t31<T>))((value) {
16 controller._add(DEVC$RT.cast(value, dynamic, T, "CastGeneral", """line 89, c olumn 25 of dart:async/stream.dart: """, value is T, false)); 16 controller._add(DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 89, column 25 of dart:async/stream.dart: """, value is T, false));
17 controller._closeUnchecked(); 17 controller._closeUnchecked();
18 } 18 }
19 ), onError: (error, stackTrace) { 19 ), onError: (error, stackTrace) {
20 controller._addError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "C astGeneral", """line 93, column 37 of dart:async/stream.dart: """, stackTrace is StackTrace, true)); 20 controller._addError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "D ynamicCast", """line 93, column 37 of dart:async/stream.dart: """, stackTrace is StackTrace, true));
21 controller._closeUnchecked(); 21 controller._closeUnchecked();
22 } 22 }
23 ); 23 );
24 return controller.stream; 24 return controller.stream;
25 } 25 }
26 factory Stream.fromIterable(Iterable<T> data) { 26 factory Stream.fromIterable(Iterable<T> data) {
27 return new _GeneratedStreamImpl<T>(() => new _IterablePendingEvents<T>(data)); 27 return new _GeneratedStreamImpl<T>(() => new _IterablePendingEvents<T>(data));
28 } 28 }
29 factory Stream.periodic(Duration period, [T computation(int computationCount)]) { 29 factory Stream.periodic(Duration period, [T computation(int computationCount)]) {
30 if (computation == null) computation = ((__x41) => DEVC$RT.wrap((dynamic f(dyn amic __u36)) { 30 if (computation == null) computation = ((__x41) => DEVC$RT.wrap((dynamic f(dyn amic __u36)) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 timer = null; 73 timer = null;
74 } 74 }
75 ); 75 );
76 return controller.stream; 76 return controller.stream;
77 } 77 }
78 factory Stream.eventTransformed(Stream source, EventSink mapSink(EventSink<T> s ink)) { 78 factory Stream.eventTransformed(Stream source, EventSink mapSink(EventSink<T> s ink)) {
79 return ((__x42) => DEVC$RT.cast(__x42, DEVC$RT.type((_BoundSinkStream<dynamic, dynamic> _) { 79 return ((__x42) => DEVC$RT.cast(__x42, DEVC$RT.type((_BoundSinkStream<dynamic, dynamic> _) {
80 } 80 }
81 ), DEVC$RT.type((Stream<T> _) { 81 ), DEVC$RT.type((Stream<T> _) {
82 } 82 }
83 ), "CastExact", """line 216, column 12 of dart:async/stream.dart: """, __x42 i s Stream<T>, false))(new _BoundSinkStream(source, DEVC$RT.wrap((EventSink<dynami c> f(EventSink<T> __u43)) { 83 ), "InferableAllocation", """line 216, column 12 of dart:async/stream.dart: "" ", __x42 is Stream<T>, false))(new _BoundSinkStream(source, DEVC$RT.wrap((EventS ink<dynamic> f(EventSink<T> __u43)) {
84 EventSink<dynamic> c(EventSink<T> x0) => f(DEVC$RT.cast(x0, DEVC$RT.type((Ev entSink<dynamic> _) { 84 EventSink<dynamic> c(EventSink<T> x0) => f(DEVC$RT.cast(x0, DEVC$RT.type((Ev entSink<dynamic> _) {
85 } 85 }
86 ), DEVC$RT.type((EventSink<T> _) { 86 ), DEVC$RT.type((EventSink<T> _) {
87 } 87 }
88 ), "CastParam", """line 216, column 41 of dart:async/stream.dart: """, x0 is EventSink<T>, false)); 88 ), "CastParam", """line 216, column 41 of dart:async/stream.dart: """, x0 is EventSink<T>, false));
89 return f == null ? null : c; 89 return f == null ? null : c;
90 } 90 }
91 , mapSink, DEVC$RT.type((__t46<T> _) { 91 , mapSink, DEVC$RT.type((__t46<T> _) {
92 } 92 }
93 ), __t44, "Wrap", """line 216, column 41 of dart:async/stream.dart: """, mapSi nk is __t44))); 93 ), __t44, "Wrap", """line 216, column 41 of dart:async/stream.dart: """, mapSi nk is __t44)));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 controller.addError(e, s); 143 controller.addError(e, s);
144 return;} 144 return;}
145 if (newValue is Future) { 145 if (newValue is Future) {
146 subscription.pause(); 146 subscription.pause();
147 newValue.then(add, onError: addError).whenComplete(subscription.resume) ; 147 newValue.then(add, onError: addError).whenComplete(subscription.resume) ;
148 } 148 }
149 else { 149 else {
150 controller.add(newValue); 150 controller.add(newValue);
151 } 151 }
152 } 152 }
153 , onError: DEVC$RT.cast(addError, dynamic, Function, "CastGeneral", """line 338, column 20 of dart:async/stream.dart: """, addError is Function, true), onDo ne: controller.close); 153 , onError: DEVC$RT.cast(addError, dynamic, Function, "DynamicCast", """line 338, column 20 of dart:async/stream.dart: """, addError is Function, true), onDo ne: controller.close);
154 } 154 }
155 if (this.isBroadcast) { 155 if (this.isBroadcast) {
156 controller = new StreamController.broadcast(onListen: onListen, onCancel: () { 156 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
157 subscription.cancel(); 157 subscription.cancel();
158 } 158 }
159 , sync: true); 159 , sync: true);
160 } 160 }
161 else { 161 else {
162 controller = new StreamController(onListen: onListen, onPause: () { 162 controller = new StreamController(onListen: onListen, onPause: () {
163 subscription.pause(); 163 subscription.pause();
(...skipping 19 matching lines...) Expand all
183 newStream = convert(event); 183 newStream = convert(event);
184 } 184 }
185 catch (e, s) { 185 catch (e, s) {
186 controller.addError(e, s); 186 controller.addError(e, s);
187 return;} 187 return;}
188 if (newStream != null) { 188 if (newStream != null) {
189 subscription.pause(); 189 subscription.pause();
190 controller.addStream(newStream).whenComplete(subscription.resume); 190 controller.addStream(newStream).whenComplete(subscription.resume);
191 } 191 }
192 } 192 }
193 , onError: DEVC$RT.cast(eventSink._addError, dynamic, Function, "CastGeneral ", """line 395, column 20 of dart:async/stream.dart: """, eventSink._addError is Function, true), onDone: controller.close); 193 , onError: DEVC$RT.cast(eventSink._addError, dynamic, Function, "DynamicCast ", """line 395, column 20 of dart:async/stream.dart: """, eventSink._addError is Function, true), onDone: controller.close);
194 } 194 }
195 if (this.isBroadcast) { 195 if (this.isBroadcast) {
196 controller = new StreamController.broadcast(onListen: onListen, onCancel: () { 196 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
197 subscription.cancel(); 197 subscription.cancel();
198 } 198 }
199 , sync: true); 199 , sync: true);
200 } 200 }
201 else { 201 else {
202 controller = new StreamController(onListen: onListen, onPause: () { 202 controller = new StreamController(onListen: onListen, onPause: () {
203 subscription.pause(); 203 subscription.pause();
(...skipping 25 matching lines...) Expand all
229 Future<T> reduce(T combine(T previous, T element)) { 229 Future<T> reduce(T combine(T previous, T element)) {
230 _Future<T> result = new _Future<T>(); 230 _Future<T> result = new _Future<T>();
231 bool seenFirst = false; 231 bool seenFirst = false;
232 T value; 232 T value;
233 StreamSubscription subscription; 233 StreamSubscription subscription;
234 subscription = this.listen((T element) { 234 subscription = this.listen((T element) {
235 if (seenFirst) { 235 if (seenFirst) {
236 _runUserCode(() => combine(value, element), (T newValue) { 236 _runUserCode(() => combine(value, element), (T newValue) {
237 value = newValue; 237 value = newValue;
238 } 238 }
239 , ((__x57) => DEVC$RT.cast(__x57, dynamic, __t54, "CastGeneral", """line 5 01, column 24 of dart:async/stream.dart: """, __x57 is __t54, false))(_cancelAnd ErrorClosure(subscription, result))); 239 , ((__x57) => DEVC$RT.cast(__x57, dynamic, __t54, "CompositeCast", """line 501, column 24 of dart:async/stream.dart: """, __x57 is __t54, false))(_cancelA ndErrorClosure(subscription, result)));
240 } 240 }
241 else { 241 else {
242 value = element; 242 value = element;
243 seenFirst = true; 243 seenFirst = true;
244 } 244 }
245 } 245 }
246 , onError: result._completeError, onDone: () { 246 , onError: result._completeError, onDone: () {
247 if (!seenFirst) { 247 if (!seenFirst) {
248 try { 248 try {
249 throw IterableElementError.noElement(); 249 throw IterableElementError.noElement();
(...skipping 10 matching lines...) Expand all
260 return result; 260 return result;
261 } 261 }
262 Future fold(var initialValue, combine(var previous, T element)) { 262 Future fold(var initialValue, combine(var previous, T element)) {
263 _Future result = new _Future(); 263 _Future result = new _Future();
264 var value = initialValue; 264 var value = initialValue;
265 StreamSubscription subscription; 265 StreamSubscription subscription;
266 subscription = this.listen((T element) { 266 subscription = this.listen((T element) {
267 _runUserCode(() => combine(value, element), (newValue) { 267 _runUserCode(() => combine(value, element), (newValue) {
268 value = newValue; 268 value = newValue;
269 } 269 }
270 , ((__x58) => DEVC$RT.cast(__x58, dynamic, __t54, "CastGeneral", """line 534 , column 11 of dart:async/stream.dart: """, __x58 is __t54, false))(_cancelAndEr rorClosure(subscription, result))); 270 , ((__x58) => DEVC$RT.cast(__x58, dynamic, __t54, "CompositeCast", """line 5 34, column 11 of dart:async/stream.dart: """, __x58 is __t54, false))(_cancelAnd ErrorClosure(subscription, result)));
271 } 271 }
272 , onError: (e, st) { 272 , onError: (e, st) {
273 result._completeError(e, DEVC$RT.cast(st, dynamic, StackTrace, "CastGeneral" , """line 538, column 34 of dart:async/stream.dart: """, st is StackTrace, true) ); 273 result._completeError(e, DEVC$RT.cast(st, dynamic, StackTrace, "DynamicCast" , """line 538, column 34 of dart:async/stream.dart: """, st is StackTrace, true) );
274 } 274 }
275 , onDone: () { 275 , onDone: () {
276 result._complete(value); 276 result._complete(value);
277 } 277 }
278 , cancelOnError: true); 278 , cancelOnError: true);
279 return result; 279 return result;
280 } 280 }
281 Future<String> join([String separator = ""]) { 281 Future<String> join([String separator = ""]) {
282 _Future<String> result = new _Future<String>(); 282 _Future<String> result = new _Future<String>();
283 StringBuffer buffer = new StringBuffer(); 283 StringBuffer buffer = new StringBuffer();
(...skipping 22 matching lines...) Expand all
306 } 306 }
307 Future<bool> contains(Object needle) { 307 Future<bool> contains(Object needle) {
308 _Future<bool> future = new _Future<bool>(); 308 _Future<bool> future = new _Future<bool>();
309 StreamSubscription subscription; 309 StreamSubscription subscription;
310 subscription = this.listen((T element) { 310 subscription = this.listen((T element) {
311 _runUserCode(() => (element == needle), (bool isMatch) { 311 _runUserCode(() => (element == needle), (bool isMatch) {
312 if (isMatch) { 312 if (isMatch) {
313 _cancelAndValue(subscription, future, true); 313 _cancelAndValue(subscription, future, true);
314 } 314 }
315 } 315 }
316 , ((__x59) => DEVC$RT.cast(__x59, dynamic, __t54, "CastGeneral", """line 602 , column 13 of dart:async/stream.dart: """, __x59 is __t54, false))(_cancelAndEr rorClosure(subscription, future))); 316 , ((__x59) => DEVC$RT.cast(__x59, dynamic, __t54, "CompositeCast", """line 6 02, column 13 of dart:async/stream.dart: """, __x59 is __t54, false))(_cancelAnd ErrorClosure(subscription, future)));
317 } 317 }
318 , onError: future._completeError, onDone: () { 318 , onError: future._completeError, onDone: () {
319 future._complete(false); 319 future._complete(false);
320 } 320 }
321 , cancelOnError: true); 321 , cancelOnError: true);
322 return future; 322 return future;
323 } 323 }
324 Future forEach(void action(T element)) { 324 Future forEach(void action(T element)) {
325 _Future future = new _Future(); 325 _Future future = new _Future();
326 StreamSubscription subscription; 326 StreamSubscription subscription;
327 subscription = this.listen((T element) { 327 subscription = this.listen((T element) {
328 _runUserCode(() => action(element), (_) { 328 _runUserCode(() => action(element), (_) {
329 } 329 }
330 , ((__x60) => DEVC$RT.cast(__x60, dynamic, __t54, "CastGeneral", """line 628 , column 13 of dart:async/stream.dart: """, __x60 is __t54, false))(_cancelAndEr rorClosure(subscription, future))); 330 , ((__x60) => DEVC$RT.cast(__x60, dynamic, __t54, "CompositeCast", """line 6 28, column 13 of dart:async/stream.dart: """, __x60 is __t54, false))(_cancelAnd ErrorClosure(subscription, future)));
331 } 331 }
332 , onError: future._completeError, onDone: () { 332 , onError: future._completeError, onDone: () {
333 future._complete(null); 333 future._complete(null);
334 } 334 }
335 , cancelOnError: true); 335 , cancelOnError: true);
336 return future; 336 return future;
337 } 337 }
338 Future<bool> every(bool test(T element)) { 338 Future<bool> every(bool test(T element)) {
339 _Future<bool> future = new _Future<bool>(); 339 _Future<bool> future = new _Future<bool>();
340 StreamSubscription subscription; 340 StreamSubscription subscription;
341 subscription = this.listen((T element) { 341 subscription = this.listen((T element) {
342 _runUserCode(() => test(element), (bool isMatch) { 342 _runUserCode(() => test(element), (bool isMatch) {
343 if (!isMatch) { 343 if (!isMatch) {
344 _cancelAndValue(subscription, future, false); 344 _cancelAndValue(subscription, future, false);
345 } 345 }
346 } 346 }
347 , ((__x61) => DEVC$RT.cast(__x61, dynamic, __t54, "CastGeneral", """line 657 , column 13 of dart:async/stream.dart: """, __x61 is __t54, false))(_cancelAndEr rorClosure(subscription, future))); 347 , ((__x61) => DEVC$RT.cast(__x61, dynamic, __t54, "CompositeCast", """line 6 57, column 13 of dart:async/stream.dart: """, __x61 is __t54, false))(_cancelAnd ErrorClosure(subscription, future)));
348 } 348 }
349 , onError: future._completeError, onDone: () { 349 , onError: future._completeError, onDone: () {
350 future._complete(true); 350 future._complete(true);
351 } 351 }
352 , cancelOnError: true); 352 , cancelOnError: true);
353 return future; 353 return future;
354 } 354 }
355 Future<bool> any(bool test(T element)) { 355 Future<bool> any(bool test(T element)) {
356 _Future<bool> future = new _Future<bool>(); 356 _Future<bool> future = new _Future<bool>();
357 StreamSubscription subscription; 357 StreamSubscription subscription;
358 subscription = this.listen((T element) { 358 subscription = this.listen((T element) {
359 _runUserCode(() => test(element), (bool isMatch) { 359 _runUserCode(() => test(element), (bool isMatch) {
360 if (isMatch) { 360 if (isMatch) {
361 _cancelAndValue(subscription, future, true); 361 _cancelAndValue(subscription, future, true);
362 } 362 }
363 } 363 }
364 , ((__x62) => DEVC$RT.cast(__x62, dynamic, __t54, "CastGeneral", """line 694 , column 13 of dart:async/stream.dart: """, __x62 is __t54, false))(_cancelAndEr rorClosure(subscription, future))); 364 , ((__x62) => DEVC$RT.cast(__x62, dynamic, __t54, "CompositeCast", """line 6 94, column 13 of dart:async/stream.dart: """, __x62 is __t54, false))(_cancelAnd ErrorClosure(subscription, future)));
365 } 365 }
366 , onError: future._completeError, onDone: () { 366 , onError: future._completeError, onDone: () {
367 future._complete(false); 367 future._complete(false);
368 } 368 }
369 , cancelOnError: true); 369 , cancelOnError: true);
370 return future; 370 return future;
371 } 371 }
372 Future<int> get length { 372 Future<int> get length {
373 _Future<int> future = new _Future<int>(); 373 _Future<int> future = new _Future<int>();
374 int count = 0; 374 int count = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 428 }
429 , cancelOnError: true); 429 , cancelOnError: true);
430 return future; 430 return future;
431 } 431 }
432 Future drain([var futureValue]) => listen(null, cancelOnError: true).asFuture(f utureValue); 432 Future drain([var futureValue]) => listen(null, cancelOnError: true).asFuture(f utureValue);
433 Stream<T> take(int count) { 433 Stream<T> take(int count) {
434 return ((__x69) => DEVC$RT.cast(__x69, DEVC$RT.type((_TakeStream<dynamic> _) { 434 return ((__x69) => DEVC$RT.cast(__x69, DEVC$RT.type((_TakeStream<dynamic> _) {
435 } 435 }
436 ), DEVC$RT.type((Stream<T> _) { 436 ), DEVC$RT.type((Stream<T> _) {
437 } 437 }
438 ), "CastExact", """line 819, column 12 of dart:async/stream.dart: """, __x69 i s Stream<T>, false))(new _TakeStream(this, count)); 438 ), "InferableAllocation", """line 819, column 12 of dart:async/stream.dart: "" ", __x69 is Stream<T>, false))(new _TakeStream(this, count));
439 } 439 }
440 Stream<T> takeWhile(bool test(T element)) { 440 Stream<T> takeWhile(bool test(T element)) {
441 return ((__x70) => DEVC$RT.cast(__x70, DEVC$RT.type((_TakeWhileStream<dynamic> _) { 441 return ((__x70) => DEVC$RT.cast(__x70, DEVC$RT.type((_TakeWhileStream<dynamic> _) {
442 } 442 }
443 ), DEVC$RT.type((Stream<T> _) { 443 ), DEVC$RT.type((Stream<T> _) {
444 } 444 }
445 ), "CastExact", """line 841, column 12 of dart:async/stream.dart: """, __x70 i s Stream<T>, false))(new _TakeWhileStream(this, test)); 445 ), "InferableAllocation", """line 841, column 12 of dart:async/stream.dart: "" ", __x70 is Stream<T>, false))(new _TakeWhileStream(this, test));
446 } 446 }
447 Stream<T> skip(int count) { 447 Stream<T> skip(int count) {
448 return ((__x71) => DEVC$RT.cast(__x71, DEVC$RT.type((_SkipStream<dynamic> _) { 448 return ((__x71) => DEVC$RT.cast(__x71, DEVC$RT.type((_SkipStream<dynamic> _) {
449 } 449 }
450 ), DEVC$RT.type((Stream<T> _) { 450 ), DEVC$RT.type((Stream<T> _) {
451 } 451 }
452 ), "CastExact", """line 852, column 12 of dart:async/stream.dart: """, __x71 i s Stream<T>, false))(new _SkipStream(this, count)); 452 ), "InferableAllocation", """line 852, column 12 of dart:async/stream.dart: "" ", __x71 is Stream<T>, false))(new _SkipStream(this, count));
453 } 453 }
454 Stream<T> skipWhile(bool test(T element)) { 454 Stream<T> skipWhile(bool test(T element)) {
455 return ((__x72) => DEVC$RT.cast(__x72, DEVC$RT.type((_SkipWhileStream<dynamic> _) { 455 return ((__x72) => DEVC$RT.cast(__x72, DEVC$RT.type((_SkipWhileStream<dynamic> _) {
456 } 456 }
457 ), DEVC$RT.type((Stream<T> _) { 457 ), DEVC$RT.type((Stream<T> _) {
458 } 458 }
459 ), "CastExact", """line 868, column 12 of dart:async/stream.dart: """, __x72 i s Stream<T>, false))(new _SkipWhileStream(this, test)); 459 ), "InferableAllocation", """line 868, column 12 of dart:async/stream.dart: "" ", __x72 is Stream<T>, false))(new _SkipWhileStream(this, test));
460 } 460 }
461 Stream<T> distinct([bool equals(T previous, T next)]) { 461 Stream<T> distinct([bool equals(T previous, T next)]) {
462 return ((__x73) => DEVC$RT.cast(__x73, DEVC$RT.type((_DistinctStream<dynamic> _) { 462 return ((__x73) => DEVC$RT.cast(__x73, DEVC$RT.type((_DistinctStream<dynamic> _) {
463 } 463 }
464 ), DEVC$RT.type((Stream<T> _) { 464 ), DEVC$RT.type((Stream<T> _) {
465 } 465 }
466 ), "CastExact", """line 885, column 12 of dart:async/stream.dart: """, __x73 i s Stream<T>, false))(new _DistinctStream(this, equals)); 466 ), "InferableAllocation", """line 885, column 12 of dart:async/stream.dart: "" ", __x73 is Stream<T>, false))(new _DistinctStream(this, equals));
467 } 467 }
468 Future<T> get first { 468 Future<T> get first {
469 _Future<T> future = new _Future<T>(); 469 _Future<T> future = new _Future<T>();
470 StreamSubscription subscription; 470 StreamSubscription subscription;
471 subscription = this.listen((T value) { 471 subscription = this.listen((T value) {
472 _cancelAndValue(subscription, future, value); 472 _cancelAndValue(subscription, future, value);
473 } 473 }
474 , onError: future._completeError, onDone: () { 474 , onError: future._completeError, onDone: () {
475 try { 475 try {
476 throw IterableElementError.noElement(); 476 throw IterableElementError.noElement();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 Object defaultValue()} 540 Object defaultValue()}
541 ) { 541 ) {
542 _Future<dynamic> future = new _Future(); 542 _Future<dynamic> future = new _Future();
543 StreamSubscription subscription; 543 StreamSubscription subscription;
544 subscription = this.listen((T value) { 544 subscription = this.listen((T value) {
545 _runUserCode(() => test(value), (bool isMatch) { 545 _runUserCode(() => test(value), (bool isMatch) {
546 if (isMatch) { 546 if (isMatch) {
547 _cancelAndValue(subscription, future, value); 547 _cancelAndValue(subscription, future, value);
548 } 548 }
549 } 549 }
550 , ((__x74) => DEVC$RT.cast(__x74, dynamic, __t54, "CastGeneral", """line 103 6, column 11 of dart:async/stream.dart: """, __x74 is __t54, false))(_cancelAndE rrorClosure(subscription, future))); 550 , ((__x74) => DEVC$RT.cast(__x74, dynamic, __t54, "CompositeCast", """line 1 036, column 11 of dart:async/stream.dart: """, __x74 is __t54, false))(_cancelAn dErrorClosure(subscription, future)));
551 } 551 }
552 , onError: future._completeError, onDone: () { 552 , onError: future._completeError, onDone: () {
553 if (defaultValue != null) { 553 if (defaultValue != null) {
554 _runUserCode(defaultValue, future._complete, future._completeError); 554 _runUserCode(defaultValue, future._complete, future._completeError);
555 return;} 555 return;}
556 try { 556 try {
557 throw IterableElementError.noElement(); 557 throw IterableElementError.noElement();
558 } 558 }
559 catch (e, s) { 559 catch (e, s) {
560 _completeWithErrorCallback(future, e, s); 560 _completeWithErrorCallback(future, e, s);
561 } 561 }
562 } 562 }
563 , cancelOnError: true); 563 , cancelOnError: true);
564 return future; 564 return future;
565 } 565 }
566 Future<dynamic> lastWhere(bool test(T element), { 566 Future<dynamic> lastWhere(bool test(T element), {
567 Object defaultValue()} 567 Object defaultValue()}
568 ) { 568 ) {
569 _Future<dynamic> future = new _Future(); 569 _Future<dynamic> future = new _Future();
570 T result = null; 570 T result = null;
571 bool foundResult = false; 571 bool foundResult = false;
572 StreamSubscription subscription; 572 StreamSubscription subscription;
573 subscription = this.listen((T value) { 573 subscription = this.listen((T value) {
574 _runUserCode(() => true == test(value), (bool isMatch) { 574 _runUserCode(() => true == test(value), (bool isMatch) {
575 if (isMatch) { 575 if (isMatch) {
576 foundResult = true; 576 foundResult = true;
577 result = value; 577 result = value;
578 } 578 }
579 } 579 }
580 , ((__x75) => DEVC$RT.cast(__x75, dynamic, __t54, "CastGeneral", """line 107 7, column 11 of dart:async/stream.dart: """, __x75 is __t54, false))(_cancelAndE rrorClosure(subscription, future))); 580 , ((__x75) => DEVC$RT.cast(__x75, dynamic, __t54, "CompositeCast", """line 1 077, column 11 of dart:async/stream.dart: """, __x75 is __t54, false))(_cancelAn dErrorClosure(subscription, future)));
581 } 581 }
582 , onError: future._completeError, onDone: () { 582 , onError: future._completeError, onDone: () {
583 if (foundResult) { 583 if (foundResult) {
584 future._complete(result); 584 future._complete(result);
585 return;} 585 return;}
586 if (defaultValue != null) { 586 if (defaultValue != null) {
587 _runUserCode(defaultValue, future._complete, future._completeError); 587 _runUserCode(defaultValue, future._complete, future._completeError);
588 return;} 588 return;}
589 try { 589 try {
590 throw IterableElementError.noElement(); 590 throw IterableElementError.noElement();
(...skipping 18 matching lines...) Expand all
609 throw IterableElementError.tooMany(); 609 throw IterableElementError.tooMany();
610 } 610 }
611 catch (e, s) { 611 catch (e, s) {
612 _cancelAndErrorWithReplacement(subscription, future, e, s); 612 _cancelAndErrorWithReplacement(subscription, future, e, s);
613 } 613 }
614 return;} 614 return;}
615 foundResult = true; 615 foundResult = true;
616 result = value; 616 result = value;
617 } 617 }
618 } 618 }
619 , ((__x76) => DEVC$RT.cast(__x76, dynamic, __t54, "CastGeneral", """line 112 9, column 11 of dart:async/stream.dart: """, __x76 is __t54, false))(_cancelAndE rrorClosure(subscription, future))); 619 , ((__x76) => DEVC$RT.cast(__x76, dynamic, __t54, "CompositeCast", """line 1 129, column 11 of dart:async/stream.dart: """, __x76 is __t54, false))(_cancelAn dErrorClosure(subscription, future)));
620 } 620 }
621 , onError: future._completeError, onDone: () { 621 , onError: future._completeError, onDone: () {
622 if (foundResult) { 622 if (foundResult) {
623 future._complete(result); 623 future._complete(result);
624 return;} 624 return;}
625 try { 625 try {
626 throw IterableElementError.noElement(); 626 throw IterableElementError.noElement();
627 } 627 }
628 catch (e, s) { 628 catch (e, s) {
629 _completeWithErrorCallback(future, e, s); 629 _completeWithErrorCallback(future, e, s);
(...skipping 23 matching lines...) Expand all
653 void onTimeout(EventSink sink)} 653 void onTimeout(EventSink sink)}
654 ) { 654 ) {
655 StreamController controller; 655 StreamController controller;
656 StreamSubscription<T> subscription; 656 StreamSubscription<T> subscription;
657 Timer timer; 657 Timer timer;
658 Zone zone; 658 Zone zone;
659 Function timeout; 659 Function timeout;
660 void onData(T event) { 660 void onData(T event) {
661 timer.cancel(); 661 timer.cancel();
662 controller.add(event); 662 controller.add(event);
663 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CastGeneral", """line 1219, column 43 of dart:async/stream.dart: """, timeout i s __t77, false)); 663 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CompositeCast", """line 1219, column 43 of dart:async/stream.dart: """, timeout is __t77, false));
664 } 664 }
665 void onError(error, StackTrace stackTrace) { 665 void onError(error, StackTrace stackTrace) {
666 timer.cancel(); 666 timer.cancel();
667 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); var eventSink = controller; 667 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); var eventSink = controller;
668 eventSink._addError(error, stackTrace); 668 eventSink._addError(error, stackTrace);
669 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CastGeneral", """line 1227, column 43 of dart:async/stream.dart: """, timeout i s __t77, false)); 669 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CompositeCast", """line 1227, column 43 of dart:async/stream.dart: """, timeout is __t77, false));
670 } 670 }
671 void onDone() { 671 void onDone() {
672 timer.cancel(); 672 timer.cancel();
673 controller.close(); 673 controller.close();
674 } 674 }
675 void onListen() { 675 void onListen() {
676 zone = Zone.current; 676 zone = Zone.current;
677 if (onTimeout == null) { 677 if (onTimeout == null) {
678 timeout = () { 678 timeout = () {
679 controller.addError(new TimeoutException("No stream event", timeLimit), null); 679 controller.addError(new TimeoutException("No stream event", timeLimit), null);
680 } 680 }
681 ; 681 ;
682 } 682 }
683 else { 683 else {
684 onTimeout = ((__x81) => DEVC$RT.wrap((dynamic f(dynamic __u78)) { 684 onTimeout = ((__x81) => DEVC$RT.wrap((dynamic f(dynamic __u78)) {
685 dynamic c(dynamic x0) => f(x0); 685 dynamic c(dynamic x0) => f(x0);
686 return f == null ? null : c; 686 return f == null ? null : c;
687 } 687 }
688 , __x81, __t33, __t79, "Wrap", """line 1245, column 21 of dart:async/strea m.dart: """, __x81 is __t79))(zone.registerUnaryCallback(onTimeout)); 688 , __x81, __t33, __t79, "Wrap", """line 1245, column 21 of dart:async/strea m.dart: """, __x81 is __t79))(zone.registerUnaryCallback(onTimeout));
689 _ControllerEventSinkWrapper wrapper = new _ControllerEventSinkWrapper(nul l); 689 _ControllerEventSinkWrapper wrapper = new _ControllerEventSinkWrapper(nul l);
690 timeout = () { 690 timeout = () {
691 wrapper._sink = controller; 691 wrapper._sink = controller;
692 zone.runUnaryGuarded(onTimeout, wrapper); 692 zone.runUnaryGuarded(onTimeout, wrapper);
693 wrapper._sink = null; 693 wrapper._sink = null;
694 } 694 }
695 ; 695 ;
696 } 696 }
697 subscription = this.listen(onData, onError: onError, onDone: onDone); 697 subscription = this.listen(onData, onError: onError, onDone: onDone);
698 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CastGeneral", """line 1256, column 43 of dart:async/stream.dart: """, timeout i s __t77, false)); 698 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CompositeCast", """line 1256, column 43 of dart:async/stream.dart: """, timeout is __t77, false));
699 } 699 }
700 Future onCancel() { 700 Future onCancel() {
701 timer.cancel(); 701 timer.cancel();
702 Future result = subscription.cancel(); 702 Future result = subscription.cancel();
703 subscription = null; 703 subscription = null;
704 return result; 704 return result;
705 } 705 }
706 controller = isBroadcast ? new _SyncBroadcastStreamController(onListen, onCan cel) : new _SyncStreamController(onListen, () { 706 controller = isBroadcast ? new _SyncBroadcastStreamController(onListen, onCan cel) : new _SyncStreamController(onListen, () {
707 timer.cancel(); 707 timer.cancel();
708 subscription.pause(); 708 subscription.pause();
709 } 709 }
710 , () { 710 , () {
711 subscription.resume(); 711 subscription.resume();
712 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CastGeneral", """line 1275, column 53 of dart:async/stream.dart: """, timeout i s __t77, false)); 712 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __t77, "CompositeCast", """line 1275, column 53 of dart:async/stream.dart: """, timeout is __t77, false));
713 } 713 }
714 , onCancel); 714 , onCancel);
715 return controller.stream; 715 return controller.stream;
716 } 716 }
717 } 717 }
718 abstract class StreamSubscription<T> {Future cancel(); 718 abstract class StreamSubscription<T> {Future cancel();
719 void onData(void handleData(T data)); 719 void onData(void handleData(T data));
720 void onError(Function handleError); 720 void onError(Function handleError);
721 void onDone(void handleDone()); 721 void onDone(void handleDone());
722 void pause([Future resumeSignal]); 722 void pause([Future resumeSignal]);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 typedef T __t37<T>(int __u38); 774 typedef T __t37<T>(int __u38);
775 typedef dynamic __t39(dynamic __u40); 775 typedef dynamic __t39(dynamic __u40);
776 typedef EventSink<dynamic> __t44(EventSink<dynamic> __u45); 776 typedef EventSink<dynamic> __t44(EventSink<dynamic> __u45);
777 typedef EventSink<dynamic> __t46<T>(EventSink<T> __u47); 777 typedef EventSink<dynamic> __t46<T>(EventSink<T> __u47);
778 typedef void __t49(StreamSubscription<dynamic> __u50); 778 typedef void __t49(StreamSubscription<dynamic> __u50);
779 typedef void __t51<T>(StreamSubscription<T> __u52); 779 typedef void __t51<T>(StreamSubscription<T> __u52);
780 typedef dynamic __t54(dynamic __u55, StackTrace __u56); 780 typedef dynamic __t54(dynamic __u55, StackTrace __u56);
781 typedef void __t64<T>(T __u65); 781 typedef void __t64<T>(T __u65);
782 typedef void __t77(); 782 typedef void __t77();
783 typedef void __t79(EventSink<dynamic> __u80); 783 typedef void __t79(EventSink<dynamic> __u80);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/schedule_microtask.dart ('k') | test/dart_codegen/expect/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698