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

Side by Side Diff: lib/runtime/dart/async.js

Issue 1117793002: add checks needed for covariant generics, and List<E> (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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 var async; 1 var async;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic 4 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic
5 function _invokeErrorHandler(errorHandler, error, stackTrace) { 5 function _invokeErrorHandler(errorHandler, error, stackTrace) {
6 if (dart.is(errorHandler, ZoneBinaryCallback)) { 6 if (dart.is(errorHandler, ZoneBinaryCallback)) {
7 return dart.dcall(errorHandler, error, stackTrace); 7 return dart.dcall(errorHandler, error, stackTrace);
8 } else { 8 } else {
9 return dart.dcall(errorHandler, error); 9 return dart.dcall(errorHandler, error);
10 } 10 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 }); 75 });
76 return controller.stream; 76 return controller.stream;
77 } 77 }
78 fromIterable(data) { 78 fromIterable(data) {
79 return new (_GeneratedStreamImpl$(T))(() => new (_IterablePendingEvents$ (T))(data)); 79 return new (_GeneratedStreamImpl$(T))(() => new (_IterablePendingEvents$ (T))(data));
80 } 80 }
81 periodic(period, computation) { 81 periodic(period, computation) {
82 if (computation === void 0) 82 if (computation === void 0)
83 computation = null; 83 computation = null;
84 dart.as(computation, dart.functionType(T, [core.int]));
84 if (computation == null) 85 if (computation == null)
85 computation = dart.as(i => null, __CastType12); 86 computation = dart.as(i => null, __CastType12);
86 let timer = null; 87 let timer = null;
87 let computationCount = 0; 88 let computationCount = 0;
88 let controller = null; 89 let controller = null;
89 let watch = new core.Stopwatch(); 90 let watch = new core.Stopwatch();
90 // Function sendEvent: () → void 91 // Function sendEvent: () → void
91 function sendEvent() { 92 function sendEvent() {
92 watch.reset(); 93 watch.reset();
93 let data = computation((() => { 94 let data = computation((() => {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return controller.stream; 135 return controller.stream;
135 } 136 }
136 eventTransformed(source, mapSink) { 137 eventTransformed(source, mapSink) {
137 return new (_BoundSinkStream$(dart.dynamic, T))(source, dart.as(mapSink, _SinkMapper)); 138 return new (_BoundSinkStream$(dart.dynamic, T))(source, dart.as(mapSink, _SinkMapper));
138 } 139 }
139 get isBroadcast() { 140 get isBroadcast() {
140 return false; 141 return false;
141 } 142 }
142 asBroadcastStream(opts) { 143 asBroadcastStream(opts) {
143 let onListen = opts && 'onListen' in opts ? opts.onListen : null; 144 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
145 dart.as(onListen, dart.functionType(dart.void, [StreamSubscription$(T)]) );
144 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; 146 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
147 dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription$(T)]) );
145 return new (_AsBroadcastStream$(T))(this, dart.as(onListen, __CastType14 ), dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription]))); 148 return new (_AsBroadcastStream$(T))(this, dart.as(onListen, __CastType14 ), dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription])));
146 } 149 }
147 where(test) { 150 where(test) {
148 return new (_WhereStream$(T))(this, test); 151 return new (_WhereStream$(T))(this, test);
149 } 152 }
150 map(convert) { 153 map(convert) {
151 return new (_MapStream$(T, dart.dynamic))(this, convert); 154 return new (_MapStream$(T, dart.dynamic))(this, convert);
152 } 155 }
153 asyncMap(convert) { 156 asyncMap(convert) {
154 let controller = null; 157 let controller = null;
155 let subscription = null; 158 let subscription = null;
156 // Function onListen: () → void 159 // Function onListen: () → void
157 function onListen() { 160 function onListen() {
158 let add = controller.add.bind(controller); 161 let add = controller.add.bind(controller);
159 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 162 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
160 let eventSink = controller; 163 let eventSink = controller;
161 let addError = eventSink[_addError]; 164 let addError = eventSink[_addError];
162 subscription = this.listen(event => { 165 subscription = this.listen(event => {
166 dart.as(event, T);
163 let newValue = null; 167 let newValue = null;
164 try { 168 try {
165 newValue = convert(event); 169 newValue = convert(event);
166 } catch (e) { 170 } catch (e) {
167 let s = dart.stackTrace(e); 171 let s = dart.stackTrace(e);
168 controller.addError(e, s); 172 controller.addError(e, s);
169 return; 173 return;
170 } 174 }
171 175
172 if (dart.is(newValue, Future)) { 176 if (dart.is(newValue, Future)) {
(...skipping 30 matching lines...) Expand all
203 return controller.stream; 207 return controller.stream;
204 } 208 }
205 asyncExpand(convert) { 209 asyncExpand(convert) {
206 let controller = null; 210 let controller = null;
207 let subscription = null; 211 let subscription = null;
208 // Function onListen: () → void 212 // Function onListen: () → void
209 function onListen() { 213 function onListen() {
210 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 214 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
211 let eventSink = controller; 215 let eventSink = controller;
212 subscription = this.listen(event => { 216 subscription = this.listen(event => {
217 dart.as(event, T);
213 let newStream = null; 218 let newStream = null;
214 try { 219 try {
215 newStream = convert(event); 220 newStream = convert(event);
216 } catch (e) { 221 } catch (e) {
217 let s = dart.stackTrace(e); 222 let s = dart.stackTrace(e);
218 controller.addError(e, s); 223 controller.addError(e, s);
219 return; 224 return;
220 } 225 }
221 226
222 if (newStream != null) { 227 if (newStream != null) {
(...skipping 22 matching lines...) Expand all
245 onCancel: () => { 250 onCancel: () => {
246 subscription.cancel(); 251 subscription.cancel();
247 }, 252 },
248 sync: true 253 sync: true
249 }); 254 });
250 } 255 }
251 return controller.stream; 256 return controller.stream;
252 } 257 }
253 handleError(onError, opts) { 258 handleError(onError, opts) {
254 let test = opts && 'test' in opts ? opts.test : null; 259 let test = opts && 'test' in opts ? opts.test : null;
260 dart.as(test, dart.functionType(core.bool, [dart.dynamic]));
255 return new (_HandleErrorStream$(T))(this, onError, test); 261 return new (_HandleErrorStream$(T))(this, onError, test);
256 } 262 }
257 expand(convert) { 263 expand(convert) {
258 return new (_ExpandStream$(T, dart.dynamic))(this, convert); 264 return new (_ExpandStream$(T, dart.dynamic))(this, convert);
259 } 265 }
260 pipe(streamConsumer) { 266 pipe(streamConsumer) {
261 return streamConsumer.addStream(this).then(_ => streamConsumer.close()); 267 return streamConsumer.addStream(this).then(_ => streamConsumer.close());
262 } 268 }
263 transform(streamTransformer) { 269 transform(streamTransformer) {
264 return streamTransformer.bind(this); 270 return streamTransformer.bind(this);
265 } 271 }
266 reduce(combine) { 272 reduce(combine) {
267 let result = new (_Future$(T))(); 273 let result = new (_Future$(T))();
268 let seenFirst = false; 274 let seenFirst = false;
269 let value = null; 275 let value = null;
270 let subscription = null; 276 let subscription = null;
271 subscription = this.listen(element => { 277 subscription = this.listen(element => {
278 dart.as(element, T);
272 if (seenFirst) { 279 if (seenFirst) {
273 _runUserCode(() => combine(value, element), newValue => { 280 _runUserCode(() => combine(value, element), newValue => {
281 dart.as(newValue, T);
274 value = newValue; 282 value = newValue;
275 }, dart.as(_cancelAndErrorClosure(subscription, result), __CastType1 6)); 283 }, dart.as(_cancelAndErrorClosure(subscription, result), __CastType1 6));
276 } else { 284 } else {
277 value = element; 285 value = element;
278 seenFirst = true; 286 seenFirst = true;
279 } 287 }
280 }, { 288 }, {
281 onError: result[_completeError].bind(result), 289 onError: result[_completeError].bind(result),
282 onDone: () => { 290 onDone: () => {
283 if (!dart.notNull(seenFirst)) { 291 if (!dart.notNull(seenFirst)) {
(...skipping 10 matching lines...) Expand all
294 }, 302 },
295 cancelOnError: true 303 cancelOnError: true
296 }); 304 });
297 return result; 305 return result;
298 } 306 }
299 fold(initialValue, combine) { 307 fold(initialValue, combine) {
300 let result = new _Future(); 308 let result = new _Future();
301 let value = initialValue; 309 let value = initialValue;
302 let subscription = null; 310 let subscription = null;
303 subscription = this.listen(element => { 311 subscription = this.listen(element => {
312 dart.as(element, T);
304 _runUserCode(() => dart.dcall(combine, value, element), newValue => { 313 _runUserCode(() => dart.dcall(combine, value, element), newValue => {
305 value = newValue; 314 value = newValue;
306 }, dart.as(_cancelAndErrorClosure(subscription, result), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 315 }, dart.as(_cancelAndErrorClosure(subscription, result), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
307 }, { 316 }, {
308 onError: (e, st) => { 317 onError: (e, st) => {
309 result[_completeError](e, dart.as(st, core.StackTrace)); 318 result[_completeError](e, dart.as(st, core.StackTrace));
310 }, 319 },
311 onDone: () => { 320 onDone: () => {
312 result[_complete](value); 321 result[_complete](value);
313 }, 322 },
314 cancelOnError: true 323 cancelOnError: true
315 }); 324 });
316 return result; 325 return result;
317 } 326 }
318 join(separator) { 327 join(separator) {
319 if (separator === void 0) 328 if (separator === void 0)
320 separator = ""; 329 separator = "";
321 let result = new (_Future$(core.String))(); 330 let result = new (_Future$(core.String))();
322 let buffer = new core.StringBuffer(); 331 let buffer = new core.StringBuffer();
323 let subscription = null; 332 let subscription = null;
324 let first = true; 333 let first = true;
325 subscription = this.listen(element => { 334 subscription = this.listen(element => {
335 dart.as(element, T);
326 if (!dart.notNull(first)) { 336 if (!dart.notNull(first)) {
327 buffer.write(separator); 337 buffer.write(separator);
328 } 338 }
329 first = false; 339 first = false;
330 try { 340 try {
331 buffer.write(element); 341 buffer.write(element);
332 } catch (e) { 342 } catch (e) {
333 let s = dart.stackTrace(e); 343 let s = dart.stackTrace(e);
334 _cancelAndErrorWithReplacement(subscription, result, e, s); 344 _cancelAndErrorWithReplacement(subscription, result, e, s);
335 } 345 }
336 346
337 }, { 347 }, {
338 onError: e => { 348 onError: e => {
339 result[_completeError](e); 349 result[_completeError](e);
340 }, 350 },
341 onDone: () => { 351 onDone: () => {
342 result[_complete](dart.toString(buffer)); 352 result[_complete](dart.toString(buffer));
343 }, 353 },
344 cancelOnError: true 354 cancelOnError: true
345 }); 355 });
346 return result; 356 return result;
347 } 357 }
348 contains(needle) { 358 contains(needle) {
349 let future = new (_Future$(core.bool))(); 359 let future = new (_Future$(core.bool))();
350 let subscription = null; 360 let subscription = null;
351 subscription = this.listen(element => { 361 subscription = this.listen(element => {
362 dart.as(element, T);
352 _runUserCode(() => dart.equals(element, needle), isMatch => { 363 _runUserCode(() => dart.equals(element, needle), isMatch => {
353 if (isMatch) { 364 if (isMatch) {
354 _cancelAndValue(subscription, future, true); 365 _cancelAndValue(subscription, future, true);
355 } 366 }
356 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 367 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
357 }, { 368 }, {
358 onError: future[_completeError].bind(future), 369 onError: future[_completeError].bind(future),
359 onDone: () => { 370 onDone: () => {
360 future[_complete](false); 371 future[_complete](false);
361 }, 372 },
362 cancelOnError: true 373 cancelOnError: true
363 }); 374 });
364 return future; 375 return future;
365 } 376 }
366 forEach(action) { 377 forEach(action) {
367 let future = new _Future(); 378 let future = new _Future();
368 let subscription = null; 379 let subscription = null;
369 subscription = this.listen(element => { 380 subscription = this.listen(element => {
381 dart.as(element, T);
370 _runUserCode(() => action(element), _ => { 382 _runUserCode(() => action(element), _ => {
371 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 383 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
372 }, { 384 }, {
373 onError: future[_completeError].bind(future), 385 onError: future[_completeError].bind(future),
374 onDone: () => { 386 onDone: () => {
375 future[_complete](null); 387 future[_complete](null);
376 }, 388 },
377 cancelOnError: true 389 cancelOnError: true
378 }); 390 });
379 return future; 391 return future;
380 } 392 }
381 every(test) { 393 every(test) {
382 let future = new (_Future$(core.bool))(); 394 let future = new (_Future$(core.bool))();
383 let subscription = null; 395 let subscription = null;
384 subscription = this.listen(element => { 396 subscription = this.listen(element => {
397 dart.as(element, T);
385 _runUserCode(() => test(element), isMatch => { 398 _runUserCode(() => test(element), isMatch => {
386 if (!dart.notNull(isMatch)) { 399 if (!dart.notNull(isMatch)) {
387 _cancelAndValue(subscription, future, false); 400 _cancelAndValue(subscription, future, false);
388 } 401 }
389 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 402 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
390 }, { 403 }, {
391 onError: future[_completeError].bind(future), 404 onError: future[_completeError].bind(future),
392 onDone: () => { 405 onDone: () => {
393 future[_complete](true); 406 future[_complete](true);
394 }, 407 },
395 cancelOnError: true 408 cancelOnError: true
396 }); 409 });
397 return future; 410 return future;
398 } 411 }
399 any(test) { 412 any(test) {
400 let future = new (_Future$(core.bool))(); 413 let future = new (_Future$(core.bool))();
401 let subscription = null; 414 let subscription = null;
402 subscription = this.listen(element => { 415 subscription = this.listen(element => {
416 dart.as(element, T);
403 _runUserCode(() => test(element), isMatch => { 417 _runUserCode(() => test(element), isMatch => {
404 if (isMatch) { 418 if (isMatch) {
405 _cancelAndValue(subscription, future, true); 419 _cancelAndValue(subscription, future, true);
406 } 420 }
407 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 421 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
408 }, { 422 }, {
409 onError: future[_completeError].bind(future), 423 onError: future[_completeError].bind(future),
410 onDone: () => { 424 onDone: () => {
411 future[_complete](false); 425 future[_complete](false);
412 }, 426 },
(...skipping 26 matching lines...) Expand all
439 future[_complete](true); 453 future[_complete](true);
440 }, 454 },
441 cancelOnError: true 455 cancelOnError: true
442 }); 456 });
443 return future; 457 return future;
444 } 458 }
445 toList() { 459 toList() {
446 let result = dart.setType([], core.List$(T)); 460 let result = dart.setType([], core.List$(T));
447 let future = new (_Future$(core.List$(T)))(); 461 let future = new (_Future$(core.List$(T)))();
448 this.listen(data => { 462 this.listen(data => {
463 dart.as(data, T);
449 result[core.$add](data); 464 result[core.$add](data);
450 }, { 465 }, {
451 onError: future[_completeError].bind(future), 466 onError: future[_completeError].bind(future),
452 onDone: () => { 467 onDone: () => {
453 future[_complete](result); 468 future[_complete](result);
454 }, 469 },
455 cancelOnError: true 470 cancelOnError: true
456 }); 471 });
457 return future; 472 return future;
458 } 473 }
459 toSet() { 474 toSet() {
460 let result = new (core.Set$(T))(); 475 let result = new (core.Set$(T))();
461 let future = new (_Future$(core.Set$(T)))(); 476 let future = new (_Future$(core.Set$(T)))();
462 this.listen(data => { 477 this.listen(data => {
478 dart.as(data, T);
463 result.add(data); 479 result.add(data);
464 }, { 480 }, {
465 onError: future[_completeError].bind(future), 481 onError: future[_completeError].bind(future),
466 onDone: () => { 482 onDone: () => {
467 future[_complete](result); 483 future[_complete](result);
468 }, 484 },
469 cancelOnError: true 485 cancelOnError: true
470 }); 486 });
471 return future; 487 return future;
472 } 488 }
(...skipping 10 matching lines...) Expand all
483 } 499 }
484 skip(count) { 500 skip(count) {
485 return new (_SkipStream$(T))(this, count); 501 return new (_SkipStream$(T))(this, count);
486 } 502 }
487 skipWhile(test) { 503 skipWhile(test) {
488 return new (_SkipWhileStream$(T))(this, test); 504 return new (_SkipWhileStream$(T))(this, test);
489 } 505 }
490 distinct(equals) { 506 distinct(equals) {
491 if (equals === void 0) 507 if (equals === void 0)
492 equals = null; 508 equals = null;
509 dart.as(equals, dart.functionType(core.bool, [T, T]));
493 return new (_DistinctStream$(T))(this, equals); 510 return new (_DistinctStream$(T))(this, equals);
494 } 511 }
495 get first() { 512 get first() {
496 let future = new (_Future$(T))(); 513 let future = new (_Future$(T))();
497 let subscription = null; 514 let subscription = null;
498 subscription = this.listen(value => { 515 subscription = this.listen(value => {
516 dart.as(value, T);
499 _cancelAndValue(subscription, future, value); 517 _cancelAndValue(subscription, future, value);
500 }, { 518 }, {
501 onError: future[_completeError].bind(future), 519 onError: future[_completeError].bind(future),
502 onDone: () => { 520 onDone: () => {
503 try { 521 try {
504 throw _internal.IterableElementError.noElement(); 522 throw _internal.IterableElementError.noElement();
505 } catch (e) { 523 } catch (e) {
506 let s = dart.stackTrace(e); 524 let s = dart.stackTrace(e);
507 _completeWithErrorCallback(future, e, s); 525 _completeWithErrorCallback(future, e, s);
508 } 526 }
509 527
510 }, 528 },
511 cancelOnError: true 529 cancelOnError: true
512 }); 530 });
513 return future; 531 return future;
514 } 532 }
515 get last() { 533 get last() {
516 let future = new (_Future$(T))(); 534 let future = new (_Future$(T))();
517 let result = null; 535 let result = null;
518 let foundResult = false; 536 let foundResult = false;
519 let subscription = null; 537 let subscription = null;
520 subscription = this.listen(value => { 538 subscription = this.listen(value => {
539 dart.as(value, T);
521 foundResult = true; 540 foundResult = true;
522 result = value; 541 result = value;
523 }, { 542 }, {
524 onError: future[_completeError].bind(future), 543 onError: future[_completeError].bind(future),
525 onDone: () => { 544 onDone: () => {
526 if (foundResult) { 545 if (foundResult) {
527 future[_complete](result); 546 future[_complete](result);
528 return; 547 return;
529 } 548 }
530 try { 549 try {
531 throw _internal.IterableElementError.noElement(); 550 throw _internal.IterableElementError.noElement();
532 } catch (e) { 551 } catch (e) {
533 let s = dart.stackTrace(e); 552 let s = dart.stackTrace(e);
534 _completeWithErrorCallback(future, e, s); 553 _completeWithErrorCallback(future, e, s);
535 } 554 }
536 555
537 }, 556 },
538 cancelOnError: true 557 cancelOnError: true
539 }); 558 });
540 return future; 559 return future;
541 } 560 }
542 get single() { 561 get single() {
543 let future = new (_Future$(T))(); 562 let future = new (_Future$(T))();
544 let result = null; 563 let result = null;
545 let foundResult = false; 564 let foundResult = false;
546 let subscription = null; 565 let subscription = null;
547 subscription = this.listen(value => { 566 subscription = this.listen(value => {
567 dart.as(value, T);
548 if (foundResult) { 568 if (foundResult) {
549 try { 569 try {
550 throw _internal.IterableElementError.tooMany(); 570 throw _internal.IterableElementError.tooMany();
551 } catch (e) { 571 } catch (e) {
552 let s = dart.stackTrace(e); 572 let s = dart.stackTrace(e);
553 _cancelAndErrorWithReplacement(subscription, future, e, s); 573 _cancelAndErrorWithReplacement(subscription, future, e, s);
554 } 574 }
555 575
556 return; 576 return;
557 } 577 }
(...skipping 12 matching lines...) Expand all
570 let s = dart.stackTrace(e); 590 let s = dart.stackTrace(e);
571 _completeWithErrorCallback(future, e, s); 591 _completeWithErrorCallback(future, e, s);
572 } 592 }
573 593
574 }, 594 },
575 cancelOnError: true 595 cancelOnError: true
576 }); 596 });
577 return future; 597 return future;
578 } 598 }
579 firstWhere(test, opts) { 599 firstWhere(test, opts) {
600 dart.as(test, dart.functionType(core.bool, [T]));
580 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null; 601 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null;
602 dart.as(defaultValue, dart.functionType(core.Object, []));
581 let future = new _Future(); 603 let future = new _Future();
582 let subscription = null; 604 let subscription = null;
583 subscription = this.listen(value => { 605 subscription = this.listen(value => {
606 dart.as(value, T);
584 _runUserCode(() => test(value), isMatch => { 607 _runUserCode(() => test(value), isMatch => {
585 if (isMatch) { 608 if (isMatch) {
586 _cancelAndValue(subscription, future, value); 609 _cancelAndValue(subscription, future, value);
587 } 610 }
588 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 611 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
589 }, { 612 }, {
590 onError: future[_completeError].bind(future), 613 onError: future[_completeError].bind(future),
591 onDone: () => { 614 onDone: () => {
592 if (defaultValue != null) { 615 if (defaultValue != null) {
593 _runUserCode(defaultValue, future[_complete].bind(future), future[ _completeError].bind(future)); 616 _runUserCode(defaultValue, future[_complete].bind(future), future[ _completeError].bind(future));
594 return; 617 return;
595 } 618 }
596 try { 619 try {
597 throw _internal.IterableElementError.noElement(); 620 throw _internal.IterableElementError.noElement();
598 } catch (e) { 621 } catch (e) {
599 let s = dart.stackTrace(e); 622 let s = dart.stackTrace(e);
600 _completeWithErrorCallback(future, e, s); 623 _completeWithErrorCallback(future, e, s);
601 } 624 }
602 625
603 }, 626 },
604 cancelOnError: true 627 cancelOnError: true
605 }); 628 });
606 return future; 629 return future;
607 } 630 }
608 lastWhere(test, opts) { 631 lastWhere(test, opts) {
632 dart.as(test, dart.functionType(core.bool, [T]));
609 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null; 633 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null;
634 dart.as(defaultValue, dart.functionType(core.Object, []));
610 let future = new _Future(); 635 let future = new _Future();
611 let result = null; 636 let result = null;
612 let foundResult = false; 637 let foundResult = false;
613 let subscription = null; 638 let subscription = null;
614 subscription = this.listen(value => { 639 subscription = this.listen(value => {
640 dart.as(value, T);
615 _runUserCode(() => true == test(value), isMatch => { 641 _runUserCode(() => true == test(value), isMatch => {
616 if (isMatch) { 642 if (isMatch) {
617 foundResult = true; 643 foundResult = true;
618 result = value; 644 result = value;
619 } 645 }
620 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace]))); 646 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.function Type(dart.dynamic, [dart.dynamic, core.StackTrace])));
621 }, { 647 }, {
622 onError: future[_completeError].bind(future), 648 onError: future[_completeError].bind(future),
623 onDone: () => { 649 onDone: () => {
624 if (foundResult) { 650 if (foundResult) {
(...skipping 15 matching lines...) Expand all
640 cancelOnError: true 666 cancelOnError: true
641 }); 667 });
642 return future; 668 return future;
643 } 669 }
644 singleWhere(test) { 670 singleWhere(test) {
645 let future = new (_Future$(T))(); 671 let future = new (_Future$(T))();
646 let result = null; 672 let result = null;
647 let foundResult = false; 673 let foundResult = false;
648 let subscription = null; 674 let subscription = null;
649 subscription = this.listen(value => { 675 subscription = this.listen(value => {
676 dart.as(value, T);
650 _runUserCode(() => true == test(value), isMatch => { 677 _runUserCode(() => true == test(value), isMatch => {
651 if (isMatch) { 678 if (isMatch) {
652 if (foundResult) { 679 if (foundResult) {
653 try { 680 try {
654 throw _internal.IterableElementError.tooMany(); 681 throw _internal.IterableElementError.tooMany();
655 } catch (e) { 682 } catch (e) {
656 let s = dart.stackTrace(e); 683 let s = dart.stackTrace(e);
657 _cancelAndErrorWithReplacement(subscription, future, e, s); 684 _cancelAndErrorWithReplacement(subscription, future, e, s);
658 } 685 }
659 686
(...skipping 22 matching lines...) Expand all
682 }); 709 });
683 return future; 710 return future;
684 } 711 }
685 elementAt(index) { 712 elementAt(index) {
686 if (!(typeof index == 'number') || dart.notNull(index) < 0) 713 if (!(typeof index == 'number') || dart.notNull(index) < 0)
687 throw new core.ArgumentError(index); 714 throw new core.ArgumentError(index);
688 let future = new (_Future$(T))(); 715 let future = new (_Future$(T))();
689 let subscription = null; 716 let subscription = null;
690 let elementIndex = 0; 717 let elementIndex = 0;
691 subscription = this.listen(value => { 718 subscription = this.listen(value => {
719 dart.as(value, T);
692 if (index == elementIndex) { 720 if (index == elementIndex) {
693 _cancelAndValue(subscription, future, value); 721 _cancelAndValue(subscription, future, value);
694 return; 722 return;
695 } 723 }
696 elementIndex = dart.notNull(elementIndex) + 1; 724 elementIndex = dart.notNull(elementIndex) + 1;
697 }, { 725 }, {
698 onError: future[_completeError].bind(future), 726 onError: future[_completeError].bind(future),
699 onDone: (() => { 727 onDone: (() => {
700 future[_completeError](new core.RangeError.index(index, this, "index ", null, elementIndex)); 728 future[_completeError](new core.RangeError.index(index, this, "index ", null, elementIndex));
701 }).bind(this), 729 }).bind(this),
702 cancelOnError: true 730 cancelOnError: true
703 }); 731 });
704 return future; 732 return future;
705 } 733 }
706 timeout(timeLimit, opts) { 734 timeout(timeLimit, opts) {
707 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; 735 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
736 dart.as(onTimeout, dart.functionType(dart.void, [EventSink]));
708 let controller = null; 737 let controller = null;
709 let subscription = null; 738 let subscription = null;
710 let timer = null; 739 let timer = null;
711 let zone = null; 740 let zone = null;
712 let timeout = null; 741 let timeout = null;
713 // Function onData: (T) → void 742 // Function onData: (T) → void
714 function onData(event) { 743 function onData(event) {
744 dart.as(event, T);
715 timer.cancel(); 745 timer.cancel();
716 controller.add(event); 746 controller.add(event);
717 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType19)); 747 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType19));
718 } 748 }
719 // Function onError: (dynamic, StackTrace) → void 749 // Function onError: (dynamic, StackTrace) → void
720 function onError(error, stackTrace) { 750 function onError(error, stackTrace) {
721 timer.cancel(); 751 timer.cancel();
722 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 752 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
723 let eventSink = controller; 753 let eventSink = controller;
724 dart.dcall(eventSink[_addError], error, stackTrace); 754 dart.dcall(eventSink[_addError], error, stackTrace);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 dart.defineNamedConstructor(Stream, 'fromFuture'); 798 dart.defineNamedConstructor(Stream, 'fromFuture');
769 dart.defineNamedConstructor(Stream, 'fromIterable'); 799 dart.defineNamedConstructor(Stream, 'fromIterable');
770 dart.defineNamedConstructor(Stream, 'periodic'); 800 dart.defineNamedConstructor(Stream, 'periodic');
771 dart.defineNamedConstructor(Stream, 'eventTransformed'); 801 dart.defineNamedConstructor(Stream, 'eventTransformed');
772 return Stream; 802 return Stream;
773 }); 803 });
774 let Stream = Stream$(); 804 let Stream = Stream$();
775 let _StreamImpl$ = dart.generic(function(T) { 805 let _StreamImpl$ = dart.generic(function(T) {
776 class _StreamImpl extends Stream$(T) { 806 class _StreamImpl extends Stream$(T) {
777 listen(onData, opts) { 807 listen(onData, opts) {
808 dart.as(onData, dart.functionType(dart.void, [T]));
778 let onError = opts && 'onError' in opts ? opts.onError : null; 809 let onError = opts && 'onError' in opts ? opts.onError : null;
779 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 810 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
811 dart.as(onDone, dart.functionType(dart.void, []));
780 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 812 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
781 cancelOnError = core.identical(true, cancelOnError); 813 cancelOnError = core.identical(true, cancelOnError);
782 let subscription = this[_createSubscription](onData, onError, onDone, ca ncelOnError); 814 let subscription = this[_createSubscription](onData, onError, onDone, ca ncelOnError);
783 this[_onListen](subscription); 815 this[_onListen](subscription);
784 return dart.as(subscription, StreamSubscription$(T)); 816 return dart.as(subscription, StreamSubscription$(T));
785 } 817 }
786 [_createSubscription](onData, onError, onDone, cancelOnError) { 818 [_createSubscription](onData, onError, onDone, cancelOnError) {
787 return new (_BufferingStreamSubscription$(T))(onData, onError, onDone, c ancelOnError); 819 return new (_BufferingStreamSubscription$(T))(onData, onError, onDone, c ancelOnError);
788 } 820 }
789 [_onListen](subscription) {} 821 [_onListen](subscription) {}
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 this[_cancelFuture] = this[_onCancel](); 1047 this[_cancelFuture] = this[_onCancel]();
1016 } 1048 }
1017 [_incrementPauseCount]() { 1049 [_incrementPauseCount]() {
1018 this[_state] = dart.notNull(this[_state]) + dart.notNull(_BufferingStrea mSubscription._STATE_PAUSE_COUNT) | dart.notNull(_BufferingStreamSubscription._S TATE_INPUT_PAUSED); 1050 this[_state] = dart.notNull(this[_state]) + dart.notNull(_BufferingStrea mSubscription._STATE_PAUSE_COUNT) | dart.notNull(_BufferingStreamSubscription._S TATE_INPUT_PAUSED);
1019 } 1051 }
1020 [_decrementPauseCount]() { 1052 [_decrementPauseCount]() {
1021 dart.assert(this[_isPaused]); 1053 dart.assert(this[_isPaused]);
1022 this[_state] = dart.notNull(this[_state]) - dart.notNull(_BufferingStrea mSubscription._STATE_PAUSE_COUNT); 1054 this[_state] = dart.notNull(this[_state]) - dart.notNull(_BufferingStrea mSubscription._STATE_PAUSE_COUNT);
1023 } 1055 }
1024 [_add](data) { 1056 [_add](data) {
1057 dart.as(data, T);
1025 dart.assert(!dart.notNull(this[_isClosed])); 1058 dart.assert(!dart.notNull(this[_isClosed]));
1026 if (this[_isCanceled]) 1059 if (this[_isCanceled])
1027 return; 1060 return;
1028 if (this[_canFire]) { 1061 if (this[_canFire]) {
1029 this[_sendData](data); 1062 this[_sendData](data);
1030 } else { 1063 } else {
1031 this[_addPending](new _DelayedData(data)); 1064 this[_addPending](new _DelayedData(data));
1032 } 1065 }
1033 } 1066 }
1034 [_addError](error, stackTrace) { 1067 [_addError](error, stackTrace) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 pending = this[_pending] = new _StreamImplEvents(); 1100 pending = this[_pending] = new _StreamImplEvents();
1068 pending.add(event); 1101 pending.add(event);
1069 if (!dart.notNull(this[_hasPending])) { 1102 if (!dart.notNull(this[_hasPending])) {
1070 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription._STATE_HAS_PENDING); 1103 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription._STATE_HAS_PENDING);
1071 if (!dart.notNull(this[_isPaused])) { 1104 if (!dart.notNull(this[_isPaused])) {
1072 this[_pending].schedule(this); 1105 this[_pending].schedule(this);
1073 } 1106 }
1074 } 1107 }
1075 } 1108 }
1076 [_sendData](data) { 1109 [_sendData](data) {
1110 dart.as(data, T);
1077 dart.assert(!dart.notNull(this[_isCanceled])); 1111 dart.assert(!dart.notNull(this[_isCanceled]));
1078 dart.assert(!dart.notNull(this[_isPaused])); 1112 dart.assert(!dart.notNull(this[_isPaused]));
1079 dart.assert(!dart.notNull(this[_inCallback])); 1113 dart.assert(!dart.notNull(this[_inCallback]));
1080 let wasInputPaused = this[_isInputPaused]; 1114 let wasInputPaused = this[_isInputPaused];
1081 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription._STATE_IN_CALLBACK); 1115 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription._STATE_IN_CALLBACK);
1082 this[_zone].runUnaryGuarded(this[_onData], data); 1116 this[_zone].runUnaryGuarded(this[_onData], data);
1083 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription._STATE_IN_CALLBACK); 1117 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription._STATE_IN_CALLBACK);
1084 this[_checkState](wasInputPaused); 1118 this[_checkState](wasInputPaused);
1085 } 1119 }
1086 [_sendError](error, stackTrace) { 1120 [_sendError](error, stackTrace) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 [_recordPause](subscription) {} 1385 [_recordPause](subscription) {}
1352 [_recordResume](subscription) {} 1386 [_recordResume](subscription) {}
1353 [_addEventError]() { 1387 [_addEventError]() {
1354 if (this.isClosed) { 1388 if (this.isClosed) {
1355 return new core.StateError("Cannot add new events after calling close" ); 1389 return new core.StateError("Cannot add new events after calling close" );
1356 } 1390 }
1357 dart.assert(this[_isAddingStream]); 1391 dart.assert(this[_isAddingStream]);
1358 return new core.StateError("Cannot add new events while doing an addStre am"); 1392 return new core.StateError("Cannot add new events while doing an addStre am");
1359 } 1393 }
1360 add(data) { 1394 add(data) {
1395 dart.as(data, T);
1361 if (!dart.notNull(this[_mayAddEvent])) 1396 if (!dart.notNull(this[_mayAddEvent]))
1362 throw this[_addEventError](); 1397 throw this[_addEventError]();
1363 this[_sendData](data); 1398 this[_sendData](data);
1364 } 1399 }
1365 addError(error, stackTrace) { 1400 addError(error, stackTrace) {
1366 if (stackTrace === void 0) 1401 if (stackTrace === void 0)
1367 stackTrace = null; 1402 stackTrace = null;
1368 error = _nonNullError(error); 1403 error = _nonNullError(error);
1369 if (!dart.notNull(this[_mayAddEvent])) 1404 if (!dart.notNull(this[_mayAddEvent]))
1370 throw this[_addEventError](); 1405 throw this[_addEventError]();
(...skipping 13 matching lines...) Expand all
1384 throw this[_addEventError](); 1419 throw this[_addEventError]();
1385 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController._STATE_CLOSED); 1420 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController._STATE_CLOSED);
1386 let doneFuture = this[_ensureDoneFuture](); 1421 let doneFuture = this[_ensureDoneFuture]();
1387 this[_sendDone](); 1422 this[_sendDone]();
1388 return doneFuture; 1423 return doneFuture;
1389 } 1424 }
1390 get done() { 1425 get done() {
1391 return this[_ensureDoneFuture](); 1426 return this[_ensureDoneFuture]();
1392 } 1427 }
1393 addStream(stream, opts) { 1428 addStream(stream, opts) {
1429 dart.as(stream, Stream$(T));
1394 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true; 1430 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
1395 if (!dart.notNull(this[_mayAddEvent])) 1431 if (!dart.notNull(this[_mayAddEvent]))
1396 throw this[_addEventError](); 1432 throw this[_addEventError]();
1397 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController._STATE_ADDSTREAM); 1433 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController._STATE_ADDSTREAM);
1398 this[_addStreamState] = new (_AddStreamState$(T))(this, stream, cancelOn Error); 1434 this[_addStreamState] = new (_AddStreamState$(T))(this, stream, cancelOn Error);
1399 return this[_addStreamState].addStreamFuture; 1435 return this[_addStreamState].addStreamFuture;
1400 } 1436 }
1401 [_add](data) { 1437 [_add](data) {
1438 dart.as(data, T);
1402 this[_sendData](data); 1439 this[_sendData](data);
1403 } 1440 }
1404 [_addError](error, stackTrace) { 1441 [_addError](error, stackTrace) {
1405 this[_sendError](error, stackTrace); 1442 this[_sendError](error, stackTrace);
1406 } 1443 }
1407 [_close]() { 1444 [_close]() {
1408 dart.assert(this[_isAddingStream]); 1445 dart.assert(this[_isAddingStream]);
1409 let addState = this[_addStreamState]; 1446 let addState = this[_addStreamState];
1410 this[_addStreamState] = null; 1447 this[_addStreamState] = null;
1411 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStre amController._STATE_ADDSTREAM); 1448 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStre amController._STATE_ADDSTREAM);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 _BroadcastStreamController._STATE_ADDSTREAM = 8; 1493 _BroadcastStreamController._STATE_ADDSTREAM = 8;
1457 return _BroadcastStreamController; 1494 return _BroadcastStreamController;
1458 }); 1495 });
1459 let _BroadcastStreamController = _BroadcastStreamController$(); 1496 let _BroadcastStreamController = _BroadcastStreamController$();
1460 let _SyncBroadcastStreamController$ = dart.generic(function(T) { 1497 let _SyncBroadcastStreamController$ = dart.generic(function(T) {
1461 class _SyncBroadcastStreamController extends _BroadcastStreamController$(T) { 1498 class _SyncBroadcastStreamController extends _BroadcastStreamController$(T) {
1462 _SyncBroadcastStreamController(onListen, onCancel) { 1499 _SyncBroadcastStreamController(onListen, onCancel) {
1463 super._BroadcastStreamController(onListen, onCancel); 1500 super._BroadcastStreamController(onListen, onCancel);
1464 } 1501 }
1465 [_sendData](data) { 1502 [_sendData](data) {
1503 dart.as(data, T);
1466 if (this[_isEmpty]) 1504 if (this[_isEmpty])
1467 return; 1505 return;
1468 if (this[_hasOneListener]) { 1506 if (this[_hasOneListener]) {
1469 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStr eamController._STATE_FIRING); 1507 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStr eamController._STATE_FIRING);
1470 let subscription = dart.as(this[_next], _BroadcastSubscription); 1508 let subscription = dart.as(this[_next], _BroadcastSubscription);
1471 subscription[_add](data); 1509 subscription[_add](data);
1472 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastSt reamController._STATE_FIRING); 1510 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastSt reamController._STATE_FIRING);
1473 if (this[_isEmpty]) { 1511 if (this[_isEmpty]) {
1474 this[_callOnCancel](); 1512 this[_callOnCancel]();
1475 } 1513 }
(...skipping 24 matching lines...) Expand all
1500 } 1538 }
1501 return _SyncBroadcastStreamController; 1539 return _SyncBroadcastStreamController;
1502 }); 1540 });
1503 let _SyncBroadcastStreamController = _SyncBroadcastStreamController$(); 1541 let _SyncBroadcastStreamController = _SyncBroadcastStreamController$();
1504 let _AsyncBroadcastStreamController$ = dart.generic(function(T) { 1542 let _AsyncBroadcastStreamController$ = dart.generic(function(T) {
1505 class _AsyncBroadcastStreamController extends _BroadcastStreamController$(T) { 1543 class _AsyncBroadcastStreamController extends _BroadcastStreamController$(T) {
1506 _AsyncBroadcastStreamController(onListen, onCancel) { 1544 _AsyncBroadcastStreamController(onListen, onCancel) {
1507 super._BroadcastStreamController(onListen, onCancel); 1545 super._BroadcastStreamController(onListen, onCancel);
1508 } 1546 }
1509 [_sendData](data) { 1547 [_sendData](data) {
1548 dart.as(data, T);
1510 for (let link = this[_next]; !dart.notNull(core.identical(link, this)); link = link[_next]) { 1549 for (let link = this[_next]; !dart.notNull(core.identical(link, this)); link = link[_next]) {
1511 let subscription = dart.as(link, _BroadcastSubscription$(T)); 1550 let subscription = dart.as(link, _BroadcastSubscription$(T));
1512 subscription[_addPending](new _DelayedData(data)); 1551 subscription[_addPending](new _DelayedData(data));
1513 } 1552 }
1514 } 1553 }
1515 [_sendError](error, stackTrace) { 1554 [_sendError](error, stackTrace) {
1516 for (let link = this[_next]; !dart.notNull(core.identical(link, this)); link = link[_next]) { 1555 for (let link = this[_next]; !dart.notNull(core.identical(link, this)); link = link[_next]) {
1517 let subscription = dart.as(link, _BroadcastSubscription$(T)); 1556 let subscription = dart.as(link, _BroadcastSubscription$(T));
1518 subscription[_addPending](new _DelayedError(error, stackTrace)); 1557 subscription[_addPending](new _DelayedError(error, stackTrace));
1519 } 1558 }
(...skipping 24 matching lines...) Expand all
1544 get [_hasPending]() { 1583 get [_hasPending]() {
1545 return dart.notNull(this[_pending] != null) && !dart.notNull(this[_pendi ng].isEmpty); 1584 return dart.notNull(this[_pending] != null) && !dart.notNull(this[_pendi ng].isEmpty);
1546 } 1585 }
1547 [_addPendingEvent](event) { 1586 [_addPendingEvent](event) {
1548 if (this[_pending] == null) { 1587 if (this[_pending] == null) {
1549 this[_pending] = new _StreamImplEvents(); 1588 this[_pending] = new _StreamImplEvents();
1550 } 1589 }
1551 this[_pending].add(event); 1590 this[_pending].add(event);
1552 } 1591 }
1553 add(data) { 1592 add(data) {
1593 dart.as(data, T);
1554 if (!dart.notNull(this.isClosed) && dart.notNull(this[_isFiring])) { 1594 if (!dart.notNull(this.isClosed) && dart.notNull(this[_isFiring])) {
1555 this[_addPendingEvent](new (_DelayedData$(T))(data)); 1595 this[_addPendingEvent](new (_DelayedData$(T))(data));
1556 return; 1596 return;
1557 } 1597 }
1558 super.add(data); 1598 super.add(data);
1559 while (this[_hasPending]) { 1599 while (this[_hasPending]) {
1560 this[_pending].handleNext(this); 1600 this[_pending].handleNext(this);
1561 } 1601 }
1562 } 1602 }
1563 addError(error, stackTrace) { 1603 addError(error, stackTrace) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 if (replacement != null) { 1755 if (replacement != null) {
1716 error = _nonNullError(replacement.error); 1756 error = _nonNullError(replacement.error);
1717 stackTrace = replacement.stackTrace; 1757 stackTrace = replacement.stackTrace;
1718 } 1758 }
1719 } 1759 }
1720 return new _Future$(T).immediateError(error, stackTrace); 1760 return new _Future$(T).immediateError(error, stackTrace);
1721 } 1761 }
1722 delayed(duration, computation) { 1762 delayed(duration, computation) {
1723 if (computation === void 0) 1763 if (computation === void 0)
1724 computation = null; 1764 computation = null;
1765 dart.as(computation, dart.functionType(T, []));
1725 let result = new (_Future$(T))(); 1766 let result = new (_Future$(T))();
1726 new Timer(duration, () => { 1767 new Timer(duration, () => {
1727 try { 1768 try {
1728 result[_complete](computation == null ? null : computation()); 1769 result[_complete](computation == null ? null : computation());
1729 } catch (e) { 1770 } catch (e) {
1730 let s = dart.stackTrace(e); 1771 let s = dart.stackTrace(e);
1731 _completeWithErrorCallback(result, e, s); 1772 _completeWithErrorCallback(result, e, s);
1732 } 1773 }
1733 1774
1734 }); 1775 });
1735 return dart.as(result, Future$(T)); 1776 return dart.as(result, Future$(T));
1736 } 1777 }
1737 static wait(futures, opts) { 1778 static wait(futures, opts) {
1738 let eagerError = opts && 'eagerError' in opts ? opts.eagerError : false; 1779 let eagerError = opts && 'eagerError' in opts ? opts.eagerError : false;
1739 let cleanUp = opts && 'cleanUp' in opts ? opts.cleanUp : null; 1780 let cleanUp = opts && 'cleanUp' in opts ? opts.cleanUp : null;
1781 dart.as(cleanUp, dart.functionType(dart.void, [dart.dynamic]));
1740 let result = new (_Future$(core.List))(); 1782 let result = new (_Future$(core.List))();
1741 let values = null; 1783 let values = null;
1742 let remaining = 0; 1784 let remaining = 0;
1743 let error = null; 1785 let error = null;
1744 let stackTrace = null; 1786 let stackTrace = null;
1745 // Function handleError: (dynamic, dynamic) → void 1787 // Function handleError: (dynamic, dynamic) → void
1746 function handleError(theError, theStackTrace) { 1788 function handleError(theError, theStackTrace) {
1747 remaining = dart.notNull(remaining) - 1; 1789 remaining = dart.notNull(remaining) - 1;
1748 if (values != null) { 1790 if (values != null) {
1749 if (cleanUp != null) { 1791 if (cleanUp != null) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 set [_isChained](value) { 2110 set [_isChained](value) {
2069 if (value) { 2111 if (value) {
2070 dart.assert(!dart.notNull(this[_isComplete])); 2112 dart.assert(!dart.notNull(this[_isComplete]));
2071 this[_state] = _Future._CHAINED; 2113 this[_state] = _Future._CHAINED;
2072 } else { 2114 } else {
2073 dart.assert(this[_isChained]); 2115 dart.assert(this[_isChained]);
2074 this[_state] = _Future._INCOMPLETE; 2116 this[_state] = _Future._INCOMPLETE;
2075 } 2117 }
2076 } 2118 }
2077 then(f, opts) { 2119 then(f, opts) {
2120 dart.as(f, dart.functionType(dart.dynamic, [T]));
2078 let onError = opts && 'onError' in opts ? opts.onError : null; 2121 let onError = opts && 'onError' in opts ? opts.onError : null;
2079 let result = new _Future(); 2122 let result = new _Future();
2080 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) { 2123 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) {
2081 f = dart.as(result[_zone].registerUnaryCallback(f), __CastType6); 2124 f = dart.as(result[_zone].registerUnaryCallback(f), __CastType6);
2082 if (onError != null) { 2125 if (onError != null) {
2083 onError = _registerErrorHandler(onError, result[_zone]); 2126 onError = _registerErrorHandler(onError, result[_zone]);
2084 } 2127 }
2085 } 2128 }
2086 this[_addListener](new _FutureListener.then(result, f, onError)); 2129 this[_addListener](new _FutureListener.then(result, f, onError));
2087 return result; 2130 return result;
2088 } 2131 }
2089 catchError(onError, opts) { 2132 catchError(onError, opts) {
2090 let test = opts && 'test' in opts ? opts.test : null; 2133 let test = opts && 'test' in opts ? opts.test : null;
2134 dart.as(test, dart.functionType(core.bool, [dart.dynamic]));
2091 let result = new _Future(); 2135 let result = new _Future();
2092 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) { 2136 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) {
2093 onError = _registerErrorHandler(onError, result[_zone]); 2137 onError = _registerErrorHandler(onError, result[_zone]);
2094 if (test != null) 2138 if (test != null)
2095 test = dart.as(result[_zone].registerUnaryCallback(test), __CastType 8); 2139 test = dart.as(result[_zone].registerUnaryCallback(test), __CastType 8);
2096 } 2140 }
2097 this[_addListener](new _FutureListener.catchError(result, onError, test) ); 2141 this[_addListener](new _FutureListener.catchError(result, onError, test) );
2098 return result; 2142 return result;
2099 } 2143 }
2100 whenComplete(action) { 2144 whenComplete(action) {
(...skipping 14 matching lines...) Expand all
2115 } 2159 }
2116 get [_value]() { 2160 get [_value]() {
2117 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasVal ue])); 2161 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasVal ue]));
2118 return dart.as(this[_resultOrListeners], T); 2162 return dart.as(this[_resultOrListeners], T);
2119 } 2163 }
2120 get [_error]() { 2164 get [_error]() {
2121 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasErr or])); 2165 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasErr or]));
2122 return dart.as(this[_resultOrListeners], AsyncError); 2166 return dart.as(this[_resultOrListeners], AsyncError);
2123 } 2167 }
2124 [_setValue](value) { 2168 [_setValue](value) {
2169 dart.as(value, T);
2125 dart.assert(!dart.notNull(this[_isComplete])); 2170 dart.assert(!dart.notNull(this[_isComplete]));
2126 this[_state] = _Future._VALUE; 2171 this[_state] = _Future._VALUE;
2127 this[_resultOrListeners] = value; 2172 this[_resultOrListeners] = value;
2128 } 2173 }
2129 [_setErrorObject](error) { 2174 [_setErrorObject](error) {
2130 dart.assert(!dart.notNull(this[_isComplete])); 2175 dart.assert(!dart.notNull(this[_isComplete]));
2131 this[_state] = _Future._ERROR; 2176 this[_state] = _Future._ERROR;
2132 this[_resultOrListeners] = error; 2177 this[_resultOrListeners] = error;
2133 } 2178 }
2134 [_setError](error, stackTrace) { 2179 [_setError](error, stackTrace) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 result[_setValue](listenerValueOrError); 2448 result[_setValue](listenerValueOrError);
2404 } else { 2449 } else {
2405 let asyncError = dart.as(listenerValueOrError, AsyncError); 2450 let asyncError = dart.as(listenerValueOrError, AsyncError);
2406 result[_setErrorObject](asyncError); 2451 result[_setErrorObject](asyncError);
2407 } 2452 }
2408 source = result; 2453 source = result;
2409 } 2454 }
2410 } 2455 }
2411 timeout(timeLimit, opts) { 2456 timeout(timeLimit, opts) {
2412 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; 2457 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
2458 dart.as(onTimeout, dart.functionType(dart.dynamic, []));
2413 if (this[_isComplete]) 2459 if (this[_isComplete])
2414 return new _Future.immediate(this); 2460 return new _Future.immediate(this);
2415 let result = new _Future(); 2461 let result = new _Future();
2416 let timer = null; 2462 let timer = null;
2417 if (onTimeout == null) { 2463 if (onTimeout == null) {
2418 timer = new Timer(timeLimit, () => { 2464 timer = new Timer(timeLimit, () => {
2419 result[_completeError](new TimeoutException("Future not completed", timeLimit)); 2465 result[_completeError](new TimeoutException("Future not completed", timeLimit));
2420 }); 2466 });
2421 } else { 2467 } else {
2422 let zone = Zone.current; 2468 let zone = Zone.current;
2423 onTimeout = zone.registerCallback(onTimeout); 2469 onTimeout = zone.registerCallback(onTimeout);
2424 timer = new Timer(timeLimit, () => { 2470 timer = new Timer(timeLimit, () => {
2425 try { 2471 try {
2426 result[_complete](zone.run(onTimeout)); 2472 result[_complete](zone.run(onTimeout));
2427 } catch (e) { 2473 } catch (e) {
2428 let s = dart.stackTrace(e); 2474 let s = dart.stackTrace(e);
2429 result[_completeError](e, s); 2475 result[_completeError](e, s);
2430 } 2476 }
2431 2477
2432 }); 2478 });
2433 } 2479 }
2434 this.then(v => { 2480 this.then(v => {
2481 dart.as(v, T);
2435 if (timer.isActive) { 2482 if (timer.isActive) {
2436 timer.cancel(); 2483 timer.cancel();
2437 result[_completeWithValue](v); 2484 result[_completeWithValue](v);
2438 } 2485 }
2439 }, { 2486 }, {
2440 onError: (e, s) => { 2487 onError: (e, s) => {
2441 if (timer.isActive) { 2488 if (timer.isActive) {
2442 timer.cancel(); 2489 timer.cancel();
2443 result[_completeError](e, dart.as(s, core.StackTrace)); 2490 result[_completeError](e, dart.as(s, core.StackTrace));
2444 } 2491 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 class StreamView extends Stream$(T) { 2664 class StreamView extends Stream$(T) {
2618 StreamView(stream) { 2665 StreamView(stream) {
2619 this[_stream] = stream; 2666 this[_stream] = stream;
2620 super.Stream(); 2667 super.Stream();
2621 } 2668 }
2622 get isBroadcast() { 2669 get isBroadcast() {
2623 return this[_stream].isBroadcast; 2670 return this[_stream].isBroadcast;
2624 } 2671 }
2625 asBroadcastStream(opts) { 2672 asBroadcastStream(opts) {
2626 let onListen = opts && 'onListen' in opts ? opts.onListen : null; 2673 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2674 dart.as(onListen, dart.functionType(dart.void, [StreamSubscription]));
2627 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; 2675 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2676 dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription]));
2628 return this[_stream].asBroadcastStream({onListen: onListen, onCancel: on Cancel}); 2677 return this[_stream].asBroadcastStream({onListen: onListen, onCancel: on Cancel});
2629 } 2678 }
2630 listen(onData, opts) { 2679 listen(onData, opts) {
2680 dart.as(onData, dart.functionType(dart.void, [T]));
2631 let onError = opts && 'onError' in opts ? opts.onError : null; 2681 let onError = opts && 'onError' in opts ? opts.onError : null;
2632 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 2682 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
2683 dart.as(onDone, dart.functionType(dart.void, []));
2633 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 2684 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
2634 return this[_stream].listen(onData, {onError: onError, onDone: onDone, c ancelOnError: cancelOnError}); 2685 return this[_stream].listen(onData, {onError: onError, onDone: onDone, c ancelOnError: cancelOnError});
2635 } 2686 }
2636 } 2687 }
2637 return StreamView; 2688 return StreamView;
2638 }); 2689 });
2639 let StreamView = StreamView$(); 2690 let StreamView = StreamView$();
2640 let StreamConsumer$ = dart.generic(function(S) { 2691 let StreamConsumer$ = dart.generic(function(S) {
2641 class StreamConsumer extends core.Object {} 2692 class StreamConsumer extends core.Object {}
2642 return StreamConsumer; 2693 return StreamConsumer;
(...skipping 26 matching lines...) Expand all
2669 } 2720 }
2670 return StreamIterator; 2721 return StreamIterator;
2671 }); 2722 });
2672 let StreamIterator = StreamIterator$(); 2723 let StreamIterator = StreamIterator$();
2673 let _ControllerEventSinkWrapper$ = dart.generic(function(T) { 2724 let _ControllerEventSinkWrapper$ = dart.generic(function(T) {
2674 class _ControllerEventSinkWrapper extends core.Object { 2725 class _ControllerEventSinkWrapper extends core.Object {
2675 _ControllerEventSinkWrapper(sink) { 2726 _ControllerEventSinkWrapper(sink) {
2676 this[_sink] = sink; 2727 this[_sink] = sink;
2677 } 2728 }
2678 add(data) { 2729 add(data) {
2730 dart.as(data, T);
2679 this[_sink].add(data); 2731 this[_sink].add(data);
2680 } 2732 }
2681 addError(error, stackTrace) { 2733 addError(error, stackTrace) {
2682 if (stackTrace === void 0) 2734 if (stackTrace === void 0)
2683 stackTrace = null; 2735 stackTrace = null;
2684 this[_sink].addError(error, stackTrace); 2736 this[_sink].addError(error, stackTrace);
2685 } 2737 }
2686 close() { 2738 close() {
2687 this[_sink].close(); 2739 this[_sink].close();
2688 } 2740 }
2689 } 2741 }
2690 _ControllerEventSinkWrapper[dart.implements] = () => [EventSink$(T)]; 2742 _ControllerEventSinkWrapper[dart.implements] = () => [EventSink$(T)];
2691 return _ControllerEventSinkWrapper; 2743 return _ControllerEventSinkWrapper;
2692 }); 2744 });
2693 let _ControllerEventSinkWrapper = _ControllerEventSinkWrapper$(); 2745 let _ControllerEventSinkWrapper = _ControllerEventSinkWrapper$();
2694 let __CastType12$ = dart.generic(function(T) { 2746 let __CastType12$ = dart.generic(function(T) {
2695 let __CastType12 = dart.typedef('__CastType12', () => dart.functionType(T, [ core.int])); 2747 let __CastType12 = dart.typedef('__CastType12', () => dart.functionType(T, [ core.int]));
2696 return __CastType12; 2748 return __CastType12;
2697 }); 2749 });
2698 let __CastType12 = __CastType12$(); 2750 let __CastType12 = __CastType12$();
2699 let __CastType14 = dart.typedef('__CastType14', () => dart.functionType(dart.v oid, [StreamSubscription])); 2751 let __CastType14 = dart.typedef('__CastType14', () => dart.functionType(dart.v oid, [StreamSubscription]));
2700 let __CastType16 = dart.typedef('__CastType16', () => dart.functionType(dart.d ynamic, [dart.dynamic, core.StackTrace])); 2752 let __CastType16 = dart.typedef('__CastType16', () => dart.functionType(dart.d ynamic, [dart.dynamic, core.StackTrace]));
2701 let __CastType19 = dart.typedef('__CastType19', () => dart.functionType(dart.v oid, [])); 2753 let __CastType19 = dart.typedef('__CastType19', () => dart.functionType(dart.v oid, []));
2702 let __CastType20 = dart.typedef('__CastType20', () => dart.functionType(dart.v oid, [EventSink])); 2754 let __CastType20 = dart.typedef('__CastType20', () => dart.functionType(dart.v oid, [EventSink]));
2703 let StreamController$ = dart.generic(function(T) { 2755 let StreamController$ = dart.generic(function(T) {
2704 class StreamController extends core.Object { 2756 class StreamController extends core.Object {
2705 StreamController(opts) { 2757 StreamController(opts) {
2706 let onListen = opts && 'onListen' in opts ? opts.onListen : null; 2758 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2759 dart.as(onListen, dart.functionType(dart.void, []));
2707 let onPause = opts && 'onPause' in opts ? opts.onPause : null; 2760 let onPause = opts && 'onPause' in opts ? opts.onPause : null;
2761 dart.as(onPause, dart.functionType(dart.void, []));
2708 let onResume = opts && 'onResume' in opts ? opts.onResume : null; 2762 let onResume = opts && 'onResume' in opts ? opts.onResume : null;
2763 dart.as(onResume, dart.functionType(dart.void, []));
2709 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; 2764 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2765 dart.as(onCancel, dart.functionType(dart.dynamic, []));
2710 let sync = opts && 'sync' in opts ? opts.sync : false; 2766 let sync = opts && 'sync' in opts ? opts.sync : false;
2711 if (dart.notNull(onListen == null) && dart.notNull(onPause == null) && d art.notNull(onResume == null) && dart.notNull(onCancel == null)) { 2767 if (dart.notNull(onListen == null) && dart.notNull(onPause == null) && d art.notNull(onResume == null) && dart.notNull(onCancel == null)) {
2712 return dart.as(sync ? new _NoCallbackSyncStreamController() : new _NoC allbackAsyncStreamController(), StreamController$(T)); 2768 return dart.as(sync ? new _NoCallbackSyncStreamController() : new _NoC allbackAsyncStreamController(), StreamController$(T));
2713 } 2769 }
2714 return sync ? new (_SyncStreamController$(T))(onListen, onPause, onResum e, onCancel) : new (_AsyncStreamController$(T))(onListen, onPause, onResume, onC ancel); 2770 return sync ? new (_SyncStreamController$(T))(onListen, onPause, onResum e, onCancel) : new (_AsyncStreamController$(T))(onListen, onPause, onResume, onC ancel);
2715 } 2771 }
2716 broadcast(opts) { 2772 broadcast(opts) {
2717 let onListen = opts && 'onListen' in opts ? opts.onListen : null; 2773 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2774 dart.as(onListen, dart.functionType(dart.void, []));
2718 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; 2775 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2776 dart.as(onCancel, dart.functionType(dart.void, []));
2719 let sync = opts && 'sync' in opts ? opts.sync : false; 2777 let sync = opts && 'sync' in opts ? opts.sync : false;
2720 return sync ? new (_SyncBroadcastStreamController$(T))(onListen, onCance l) : new (_AsyncBroadcastStreamController$(T))(onListen, onCancel); 2778 return sync ? new (_SyncBroadcastStreamController$(T))(onListen, onCance l) : new (_AsyncBroadcastStreamController$(T))(onListen, onCancel);
2721 } 2779 }
2722 } 2780 }
2723 StreamController[dart.implements] = () => [StreamSink$(T)]; 2781 StreamController[dart.implements] = () => [StreamSink$(T)];
2724 dart.defineNamedConstructor(StreamController, 'broadcast'); 2782 dart.defineNamedConstructor(StreamController, 'broadcast');
2725 return StreamController; 2783 return StreamController;
2726 }); 2784 });
2727 let StreamController = StreamController$(); 2785 let StreamController = StreamController$();
2728 let _StreamControllerLifecycle$ = dart.generic(function(T) { 2786 let _StreamControllerLifecycle$ = dart.generic(function(T) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 return dart.as(this[_varData], _ControllerSubscription); 2863 return dart.as(this[_varData], _ControllerSubscription);
2806 } 2864 }
2807 [_badEventState]() { 2865 [_badEventState]() {
2808 if (this.isClosed) { 2866 if (this.isClosed) {
2809 return new core.StateError("Cannot add event after closing"); 2867 return new core.StateError("Cannot add event after closing");
2810 } 2868 }
2811 dart.assert(this[_isAddingStream]); 2869 dart.assert(this[_isAddingStream]);
2812 return new core.StateError("Cannot add event while adding a stream"); 2870 return new core.StateError("Cannot add event while adding a stream");
2813 } 2871 }
2814 addStream(source, opts) { 2872 addStream(source, opts) {
2873 dart.as(source, Stream$(T));
2815 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true; 2874 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
2816 if (!dart.notNull(this[_mayAddEvent])) 2875 if (!dart.notNull(this[_mayAddEvent]))
2817 throw this[_badEventState](); 2876 throw this[_badEventState]();
2818 if (this[_isCanceled]) 2877 if (this[_isCanceled])
2819 return new _Future.immediate(null); 2878 return new _Future.immediate(null);
2820 let addState = new _StreamControllerAddStreamState(this, this[_varData], source, cancelOnError); 2879 let addState = new _StreamControllerAddStreamState(this, this[_varData], source, cancelOnError);
2821 this[_varData] = addState; 2880 this[_varData] = addState;
2822 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er._STATE_ADDSTREAM); 2881 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er._STATE_ADDSTREAM);
2823 return addState.addStreamFuture; 2882 return addState.addStreamFuture;
2824 } 2883 }
2825 get done() { 2884 get done() {
2826 return this[_ensureDoneFuture](); 2885 return this[_ensureDoneFuture]();
2827 } 2886 }
2828 [_ensureDoneFuture]() { 2887 [_ensureDoneFuture]() {
2829 if (this[_doneFuture] == null) { 2888 if (this[_doneFuture] == null) {
2830 this[_doneFuture] = this[_isCanceled] ? Future._nullFuture : new _Futu re(); 2889 this[_doneFuture] = this[_isCanceled] ? Future._nullFuture : new _Futu re();
2831 } 2890 }
2832 return this[_doneFuture]; 2891 return this[_doneFuture];
2833 } 2892 }
2834 add(value) { 2893 add(value) {
2894 dart.as(value, T);
2835 if (!dart.notNull(this[_mayAddEvent])) 2895 if (!dart.notNull(this[_mayAddEvent]))
2836 throw this[_badEventState](); 2896 throw this[_badEventState]();
2837 this[_add](value); 2897 this[_add](value);
2838 } 2898 }
2839 addError(error, stackTrace) { 2899 addError(error, stackTrace) {
2840 if (stackTrace === void 0) 2900 if (stackTrace === void 0)
2841 stackTrace = null; 2901 stackTrace = null;
2842 error = _nonNullError(error); 2902 error = _nonNullError(error);
2843 if (!dart.notNull(this[_mayAddEvent])) 2903 if (!dart.notNull(this[_mayAddEvent]))
2844 throw this[_badEventState](); 2904 throw this[_badEventState]();
(...skipping 15 matching lines...) Expand all
2860 } 2920 }
2861 [_closeUnchecked]() { 2921 [_closeUnchecked]() {
2862 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er._STATE_CLOSED); 2922 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er._STATE_CLOSED);
2863 if (this.hasListener) { 2923 if (this.hasListener) {
2864 this[_sendDone](); 2924 this[_sendDone]();
2865 } else if (this[_isInitialState]) { 2925 } else if (this[_isInitialState]) {
2866 this[_ensurePendingEvents]().add(dart.const(new _DelayedDone())); 2926 this[_ensurePendingEvents]().add(dart.const(new _DelayedDone()));
2867 } 2927 }
2868 } 2928 }
2869 [_add](value) { 2929 [_add](value) {
2930 dart.as(value, T);
2870 if (this.hasListener) { 2931 if (this.hasListener) {
2871 this[_sendData](value); 2932 this[_sendData](value);
2872 } else if (this[_isInitialState]) { 2933 } else if (this[_isInitialState]) {
2873 this[_ensurePendingEvents]().add(new (_DelayedData$(T))(value)); 2934 this[_ensurePendingEvents]().add(new (_DelayedData$(T))(value));
2874 } 2935 }
2875 } 2936 }
2876 [_addError](error, stackTrace) { 2937 [_addError](error, stackTrace) {
2877 if (this.hasListener) { 2938 if (this.hasListener) {
2878 this[_sendError](error, stackTrace); 2939 this[_sendError](error, stackTrace);
2879 } else if (this[_isInitialState]) { 2940 } else if (this[_isInitialState]) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 _StreamController._STATE_CANCELED = 2; 3024 _StreamController._STATE_CANCELED = 2;
2964 _StreamController._STATE_SUBSCRIPTION_MASK = 3; 3025 _StreamController._STATE_SUBSCRIPTION_MASK = 3;
2965 _StreamController._STATE_CLOSED = 4; 3026 _StreamController._STATE_CLOSED = 4;
2966 _StreamController._STATE_ADDSTREAM = 8; 3027 _StreamController._STATE_ADDSTREAM = 8;
2967 return _StreamController; 3028 return _StreamController;
2968 }); 3029 });
2969 let _StreamController = _StreamController$(); 3030 let _StreamController = _StreamController$();
2970 let _SyncStreamControllerDispatch$ = dart.generic(function(T) { 3031 let _SyncStreamControllerDispatch$ = dart.generic(function(T) {
2971 class _SyncStreamControllerDispatch extends core.Object { 3032 class _SyncStreamControllerDispatch extends core.Object {
2972 [_sendData](data) { 3033 [_sendData](data) {
3034 dart.as(data, T);
2973 this[_subscription][_add](data); 3035 this[_subscription][_add](data);
2974 } 3036 }
2975 [_sendError](error, stackTrace) { 3037 [_sendError](error, stackTrace) {
2976 this[_subscription][_addError](error, stackTrace); 3038 this[_subscription][_addError](error, stackTrace);
2977 } 3039 }
2978 [_sendDone]() { 3040 [_sendDone]() {
2979 this[_subscription][_close](); 3041 this[_subscription][_close]();
2980 } 3042 }
2981 } 3043 }
2982 _SyncStreamControllerDispatch[dart.implements] = () => [_StreamController$(T )]; 3044 _SyncStreamControllerDispatch[dart.implements] = () => [_StreamController$(T )];
2983 return _SyncStreamControllerDispatch; 3045 return _SyncStreamControllerDispatch;
2984 }); 3046 });
2985 let _SyncStreamControllerDispatch = _SyncStreamControllerDispatch$(); 3047 let _SyncStreamControllerDispatch = _SyncStreamControllerDispatch$();
2986 let _AsyncStreamControllerDispatch$ = dart.generic(function(T) { 3048 let _AsyncStreamControllerDispatch$ = dart.generic(function(T) {
2987 class _AsyncStreamControllerDispatch extends core.Object { 3049 class _AsyncStreamControllerDispatch extends core.Object {
2988 [_sendData](data) { 3050 [_sendData](data) {
3051 dart.as(data, T);
2989 this[_subscription][_addPending](new _DelayedData(data)); 3052 this[_subscription][_addPending](new _DelayedData(data));
2990 } 3053 }
2991 [_sendError](error, stackTrace) { 3054 [_sendError](error, stackTrace) {
2992 this[_subscription][_addPending](new _DelayedError(error, stackTrace)); 3055 this[_subscription][_addPending](new _DelayedError(error, stackTrace));
2993 } 3056 }
2994 [_sendDone]() { 3057 [_sendDone]() {
2995 this[_subscription][_addPending](dart.const(new _DelayedDone())); 3058 this[_subscription][_addPending](dart.const(new _DelayedDone()));
2996 } 3059 }
2997 } 3060 }
2998 _AsyncStreamControllerDispatch[dart.implements] = () => [_StreamController$( T)]; 3061 _AsyncStreamControllerDispatch[dart.implements] = () => [_StreamController$( T)];
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 } 3120 }
3058 3121
3059 } 3122 }
3060 let _target = Symbol('_target'); 3123 let _target = Symbol('_target');
3061 let _StreamSinkWrapper$ = dart.generic(function(T) { 3124 let _StreamSinkWrapper$ = dart.generic(function(T) {
3062 class _StreamSinkWrapper extends core.Object { 3125 class _StreamSinkWrapper extends core.Object {
3063 _StreamSinkWrapper(target) { 3126 _StreamSinkWrapper(target) {
3064 this[_target] = target; 3127 this[_target] = target;
3065 } 3128 }
3066 add(data) { 3129 add(data) {
3130 dart.as(data, T);
3067 this[_target].add(data); 3131 this[_target].add(data);
3068 } 3132 }
3069 addError(error, stackTrace) { 3133 addError(error, stackTrace) {
3070 if (stackTrace === void 0) 3134 if (stackTrace === void 0)
3071 stackTrace = null; 3135 stackTrace = null;
3072 this[_target].addError(error, stackTrace); 3136 this[_target].addError(error, stackTrace);
3073 } 3137 }
3074 close() { 3138 close() {
3075 return this[_target].close(); 3139 return this[_target].close();
3076 } 3140 }
3077 addStream(source, opts) { 3141 addStream(source, opts) {
3142 dart.as(source, Stream$(T));
3078 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true; 3143 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
3079 return this[_target].addStream(source, {cancelOnError: cancelOnError}); 3144 return this[_target].addStream(source, {cancelOnError: cancelOnError});
3080 } 3145 }
3081 get done() { 3146 get done() {
3082 return this[_target].done; 3147 return this[_target].done;
3083 } 3148 }
3084 } 3149 }
3085 _StreamSinkWrapper[dart.implements] = () => [StreamSink$(T)]; 3150 _StreamSinkWrapper[dart.implements] = () => [StreamSink$(T)];
3086 return _StreamSinkWrapper; 3151 return _StreamSinkWrapper;
3087 }); 3152 });
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 function _nullDoneHandler() { 3325 function _nullDoneHandler() {
3261 } 3326 }
3262 class _DelayedEvent extends core.Object { 3327 class _DelayedEvent extends core.Object {
3263 _DelayedEvent() { 3328 _DelayedEvent() {
3264 this.next = null; 3329 this.next = null;
3265 } 3330 }
3266 } 3331 }
3267 let _DelayedData$ = dart.generic(function(T) { 3332 let _DelayedData$ = dart.generic(function(T) {
3268 class _DelayedData extends _DelayedEvent { 3333 class _DelayedData extends _DelayedEvent {
3269 _DelayedData(value) { 3334 _DelayedData(value) {
3335 dart.as(value, T);
3270 this.value = value; 3336 this.value = value;
3271 super._DelayedEvent(); 3337 super._DelayedEvent();
3272 } 3338 }
3273 perform(dispatch) { 3339 perform(dispatch) {
3274 dispatch[_sendData](this.value); 3340 dispatch[_sendData](this.value);
3275 } 3341 }
3276 } 3342 }
3277 return _DelayedData; 3343 return _DelayedData;
3278 }); 3344 });
3279 let _DelayedData = _DelayedData$(); 3345 let _DelayedData = _DelayedData$();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 this[_zone] = Zone.current; 3509 this[_zone] = Zone.current;
3444 this[_controller] = null; 3510 this[_controller] = null;
3445 this[_subscription] = null; 3511 this[_subscription] = null;
3446 super.Stream(); 3512 super.Stream();
3447 this[_controller] = new (_AsBroadcastStreamController$(T))(this[_onListe n].bind(this), this[_onCancel].bind(this)); 3513 this[_controller] = new (_AsBroadcastStreamController$(T))(this[_onListe n].bind(this), this[_onCancel].bind(this));
3448 } 3514 }
3449 get isBroadcast() { 3515 get isBroadcast() {
3450 return true; 3516 return true;
3451 } 3517 }
3452 listen(onData, opts) { 3518 listen(onData, opts) {
3519 dart.as(onData, dart.functionType(dart.void, [T]));
3453 let onError = opts && 'onError' in opts ? opts.onError : null; 3520 let onError = opts && 'onError' in opts ? opts.onError : null;
3454 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 3521 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
3522 dart.as(onDone, dart.functionType(dart.void, []));
3455 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 3523 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
3456 if (dart.notNull(this[_controller] == null) || dart.notNull(this[_contro ller].isClosed)) { 3524 if (dart.notNull(this[_controller] == null) || dart.notNull(this[_contro ller].isClosed)) {
3457 return new (_DoneStreamSubscription$(T))(onDone); 3525 return new (_DoneStreamSubscription$(T))(onDone);
3458 } 3526 }
3459 if (this[_subscription] == null) { 3527 if (this[_subscription] == null) {
3460 this[_subscription] = this[_source].listen(dart.bind(this[_controller] , 'add'), {onError: dart.bind(this[_controller], 'addError'), onDone: dart.bind( this[_controller], 'close')}); 3528 this[_subscription] = this[_source].listen(dart.bind(this[_controller] , 'add'), {onError: dart.bind(this[_controller], 'addError'), onDone: dart.bind( this[_controller], 'close')});
3461 } 3529 }
3462 cancelOnError = core.identical(true, cancelOnError); 3530 cancelOnError = core.identical(true, cancelOnError);
3463 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror); 3531 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror);
3464 } 3532 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3608 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) { 3676 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) {
3609 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool)); 3677 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
3610 this[_clear](); 3678 this[_clear]();
3611 hasNext[_complete](false); 3679 hasNext[_complete](false);
3612 } else { 3680 } else {
3613 this[_clear](); 3681 this[_clear]();
3614 } 3682 }
3615 return subscription.cancel(); 3683 return subscription.cancel();
3616 } 3684 }
3617 [_onData](data) { 3685 [_onData](data) {
3686 dart.as(data, T);
3618 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) { 3687 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) {
3619 this[_current] = data; 3688 this[_current] = data;
3620 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool)); 3689 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
3621 this[_futureOrPrefetch] = null; 3690 this[_futureOrPrefetch] = null;
3622 this[_state] = _StreamIteratorImpl._STATE_FOUND; 3691 this[_state] = _StreamIteratorImpl._STATE_FOUND;
3623 hasNext[_complete](true); 3692 hasNext[_complete](true);
3624 return; 3693 return;
3625 } 3694 }
3626 this[_subscription].pause(); 3695 this[_subscription].pause();
3627 dart.assert(this[_futureOrPrefetch] == null); 3696 dart.assert(this[_futureOrPrefetch] == null);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 let _ForwardingStream$ = dart.generic(function(S, T) { 3794 let _ForwardingStream$ = dart.generic(function(S, T) {
3726 class _ForwardingStream extends Stream$(T) { 3795 class _ForwardingStream extends Stream$(T) {
3727 _ForwardingStream(source) { 3796 _ForwardingStream(source) {
3728 this[_source] = source; 3797 this[_source] = source;
3729 super.Stream(); 3798 super.Stream();
3730 } 3799 }
3731 get isBroadcast() { 3800 get isBroadcast() {
3732 return this[_source].isBroadcast; 3801 return this[_source].isBroadcast;
3733 } 3802 }
3734 listen(onData, opts) { 3803 listen(onData, opts) {
3804 dart.as(onData, dart.functionType(dart.void, [T]));
3735 let onError = opts && 'onError' in opts ? opts.onError : null; 3805 let onError = opts && 'onError' in opts ? opts.onError : null;
3736 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 3806 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
3807 dart.as(onDone, dart.functionType(dart.void, []));
3737 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 3808 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
3738 cancelOnError = core.identical(true, cancelOnError); 3809 cancelOnError = core.identical(true, cancelOnError);
3739 return this[_createSubscription](onData, onError, onDone, cancelOnError) ; 3810 return this[_createSubscription](onData, onError, onDone, cancelOnError) ;
3740 } 3811 }
3741 [_createSubscription](onData, onError, onDone, cancelOnError) { 3812 [_createSubscription](onData, onError, onDone, cancelOnError) {
3742 return new (_ForwardingStreamSubscription$(S, T))(this, onData, onError, onDone, cancelOnError); 3813 return new (_ForwardingStreamSubscription$(S, T))(this, onData, onError, onDone, cancelOnError);
3743 } 3814 }
3744 [_handleData](data, sink) { 3815 [_handleData](data, sink) {
3816 dart.as(data, S);
3817 dart.as(sink, _EventSink$(T));
3745 let outputData = data; 3818 let outputData = data;
3746 sink[_add](outputData); 3819 sink[_add](outputData);
3747 } 3820 }
3748 [_handleError](error, stackTrace, sink) { 3821 [_handleError](error, stackTrace, sink) {
3749 sink[_addError](error, stackTrace); 3822 sink[_addError](error, stackTrace);
3750 } 3823 }
3751 [_handleDone](sink) { 3824 [_handleDone](sink) {
3752 sink[_close](); 3825 sink[_close]();
3753 } 3826 }
3754 } 3827 }
3755 return _ForwardingStream; 3828 return _ForwardingStream;
3756 }); 3829 });
3757 let _ForwardingStream = _ForwardingStream$(); 3830 let _ForwardingStream = _ForwardingStream$();
3758 let _ForwardingStreamSubscription$ = dart.generic(function(S, T) { 3831 let _ForwardingStreamSubscription$ = dart.generic(function(S, T) {
3759 class _ForwardingStreamSubscription extends _BufferingStreamSubscription$(T) { 3832 class _ForwardingStreamSubscription extends _BufferingStreamSubscription$(T) {
3760 _ForwardingStreamSubscription(stream, onData, onError, onDone, cancelOnErr or) { 3833 _ForwardingStreamSubscription(stream, onData, onError, onDone, cancelOnErr or) {
3761 this[_stream] = stream; 3834 this[_stream] = stream;
3762 this[_subscription] = null; 3835 this[_subscription] = null;
3763 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r); 3836 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r);
3764 this[_subscription] = this[_stream][_source].listen(this[_handleData].bi nd(this), {onError: this[_handleError].bind(this), onDone: this[_handleDone].bin d(this)}); 3837 this[_subscription] = this[_stream][_source].listen(this[_handleData].bi nd(this), {onError: this[_handleError].bind(this), onDone: this[_handleDone].bin d(this)});
3765 } 3838 }
3766 [_add](data) { 3839 [_add](data) {
3840 dart.as(data, T);
3767 if (this[_isClosed]) 3841 if (this[_isClosed])
3768 return; 3842 return;
3769 super[_add](data); 3843 super[_add](data);
3770 } 3844 }
3771 [_addError](error, stackTrace) { 3845 [_addError](error, stackTrace) {
3772 if (this[_isClosed]) 3846 if (this[_isClosed])
3773 return; 3847 return;
3774 super[_addError](error, stackTrace); 3848 super[_addError](error, stackTrace);
3775 } 3849 }
3776 [_onPause]() { 3850 [_onPause]() {
3777 if (this[_subscription] == null) 3851 if (this[_subscription] == null)
3778 return; 3852 return;
3779 this[_subscription].pause(); 3853 this[_subscription].pause();
3780 } 3854 }
3781 [_onResume]() { 3855 [_onResume]() {
3782 if (this[_subscription] == null) 3856 if (this[_subscription] == null)
3783 return; 3857 return;
3784 this[_subscription].resume(); 3858 this[_subscription].resume();
3785 } 3859 }
3786 [_onCancel]() { 3860 [_onCancel]() {
3787 if (this[_subscription] != null) { 3861 if (this[_subscription] != null) {
3788 let subscription = this[_subscription]; 3862 let subscription = this[_subscription];
3789 this[_subscription] = null; 3863 this[_subscription] = null;
3790 subscription.cancel(); 3864 subscription.cancel();
3791 } 3865 }
3792 return null; 3866 return null;
3793 } 3867 }
3794 [_handleData](data) { 3868 [_handleData](data) {
3869 dart.as(data, S);
3795 this[_stream][_handleData](data, this); 3870 this[_stream][_handleData](data, this);
3796 } 3871 }
3797 [_handleError](error, stackTrace) { 3872 [_handleError](error, stackTrace) {
3798 this[_stream][_handleError](error, stackTrace, this); 3873 this[_stream][_handleError](error, stackTrace, this);
3799 } 3874 }
3800 [_handleDone]() { 3875 [_handleDone]() {
3801 this[_stream][_handleDone](this); 3876 this[_stream][_handleDone](this);
3802 } 3877 }
3803 } 3878 }
3804 return _ForwardingStreamSubscription; 3879 return _ForwardingStreamSubscription;
(...skipping 14 matching lines...) Expand all
3819 sink[_addError](error, dart.as(stackTrace, core.StackTrace)); 3894 sink[_addError](error, dart.as(stackTrace, core.StackTrace));
3820 } 3895 }
3821 let _test = Symbol('_test'); 3896 let _test = Symbol('_test');
3822 let _WhereStream$ = dart.generic(function(T) { 3897 let _WhereStream$ = dart.generic(function(T) {
3823 class _WhereStream extends _ForwardingStream$(T, T) { 3898 class _WhereStream extends _ForwardingStream$(T, T) {
3824 _WhereStream(source, test) { 3899 _WhereStream(source, test) {
3825 this[_test] = test; 3900 this[_test] = test;
3826 super._ForwardingStream(source); 3901 super._ForwardingStream(source);
3827 } 3902 }
3828 [_handleData](inputEvent, sink) { 3903 [_handleData](inputEvent, sink) {
3904 dart.as(inputEvent, T);
3905 dart.as(sink, _EventSink$(T));
3829 let satisfies = null; 3906 let satisfies = null;
3830 try { 3907 try {
3831 satisfies = this[_test](inputEvent); 3908 satisfies = this[_test](inputEvent);
3832 } catch (e) { 3909 } catch (e) {
3833 let s = dart.stackTrace(e); 3910 let s = dart.stackTrace(e);
3834 _addErrorWithReplacement(sink, e, s); 3911 _addErrorWithReplacement(sink, e, s);
3835 return; 3912 return;
3836 } 3913 }
3837 3914
3838 if (satisfies) { 3915 if (satisfies) {
(...skipping 10 matching lines...) Expand all
3849 }); 3926 });
3850 let _Transformation = _Transformation$(); 3927 let _Transformation = _Transformation$();
3851 let _transform = Symbol('_transform'); 3928 let _transform = Symbol('_transform');
3852 let _MapStream$ = dart.generic(function(S, T) { 3929 let _MapStream$ = dart.generic(function(S, T) {
3853 class _MapStream extends _ForwardingStream$(S, T) { 3930 class _MapStream extends _ForwardingStream$(S, T) {
3854 _MapStream(source, transform) { 3931 _MapStream(source, transform) {
3855 this[_transform] = transform; 3932 this[_transform] = transform;
3856 super._ForwardingStream(source); 3933 super._ForwardingStream(source);
3857 } 3934 }
3858 [_handleData](inputEvent, sink) { 3935 [_handleData](inputEvent, sink) {
3936 dart.as(inputEvent, S);
3937 dart.as(sink, _EventSink$(T));
3859 let outputEvent = null; 3938 let outputEvent = null;
3860 try { 3939 try {
3861 outputEvent = dart.as(dart.dcall(this[_transform], inputEvent), T); 3940 outputEvent = dart.as(dart.dcall(this[_transform], inputEvent), T);
3862 } catch (e) { 3941 } catch (e) {
3863 let s = dart.stackTrace(e); 3942 let s = dart.stackTrace(e);
3864 _addErrorWithReplacement(sink, e, s); 3943 _addErrorWithReplacement(sink, e, s);
3865 return; 3944 return;
3866 } 3945 }
3867 3946
3868 sink[_add](outputEvent); 3947 sink[_add](outputEvent);
3869 } 3948 }
3870 } 3949 }
3871 return _MapStream; 3950 return _MapStream;
3872 }); 3951 });
3873 let _MapStream = _MapStream$(); 3952 let _MapStream = _MapStream$();
3874 let _expand = Symbol('_expand'); 3953 let _expand = Symbol('_expand');
3875 let _ExpandStream$ = dart.generic(function(S, T) { 3954 let _ExpandStream$ = dart.generic(function(S, T) {
3876 class _ExpandStream extends _ForwardingStream$(S, T) { 3955 class _ExpandStream extends _ForwardingStream$(S, T) {
3877 _ExpandStream(source, expand) { 3956 _ExpandStream(source, expand) {
3878 this[_expand] = expand; 3957 this[_expand] = expand;
3879 super._ForwardingStream(source); 3958 super._ForwardingStream(source);
3880 } 3959 }
3881 [_handleData](inputEvent, sink) { 3960 [_handleData](inputEvent, sink) {
3961 dart.as(inputEvent, S);
3962 dart.as(sink, _EventSink$(T));
3882 try { 3963 try {
3883 for (let value of this[_expand](inputEvent)) { 3964 for (let value of this[_expand](inputEvent)) {
3884 sink[_add](value); 3965 sink[_add](value);
3885 } 3966 }
3886 } catch (e) { 3967 } catch (e) {
3887 let s = dart.stackTrace(e); 3968 let s = dart.stackTrace(e);
3888 _addErrorWithReplacement(sink, e, s); 3969 _addErrorWithReplacement(sink, e, s);
3889 } 3970 }
3890 3971
3891 } 3972 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 let _remaining = Symbol('_remaining'); 4018 let _remaining = Symbol('_remaining');
3938 let _TakeStream$ = dart.generic(function(T) { 4019 let _TakeStream$ = dart.generic(function(T) {
3939 class _TakeStream extends _ForwardingStream$(T, T) { 4020 class _TakeStream extends _ForwardingStream$(T, T) {
3940 _TakeStream(source, count) { 4021 _TakeStream(source, count) {
3941 this[_remaining] = count; 4022 this[_remaining] = count;
3942 super._ForwardingStream(source); 4023 super._ForwardingStream(source);
3943 if (!(typeof count == 'number')) 4024 if (!(typeof count == 'number'))
3944 throw new core.ArgumentError(count); 4025 throw new core.ArgumentError(count);
3945 } 4026 }
3946 [_handleData](inputEvent, sink) { 4027 [_handleData](inputEvent, sink) {
4028 dart.as(inputEvent, T);
4029 dart.as(sink, _EventSink$(T));
3947 if (dart.notNull(this[_remaining]) > 0) { 4030 if (dart.notNull(this[_remaining]) > 0) {
3948 sink[_add](inputEvent); 4031 sink[_add](inputEvent);
3949 this[_remaining] = dart.notNull(this[_remaining]) - 1; 4032 this[_remaining] = dart.notNull(this[_remaining]) - 1;
3950 if (this[_remaining] == 0) { 4033 if (this[_remaining] == 0) {
3951 sink[_close](); 4034 sink[_close]();
3952 } 4035 }
3953 } 4036 }
3954 } 4037 }
3955 } 4038 }
3956 return _TakeStream; 4039 return _TakeStream;
3957 }); 4040 });
3958 let _TakeStream = _TakeStream$(); 4041 let _TakeStream = _TakeStream$();
3959 let _TakeWhileStream$ = dart.generic(function(T) { 4042 let _TakeWhileStream$ = dart.generic(function(T) {
3960 class _TakeWhileStream extends _ForwardingStream$(T, T) { 4043 class _TakeWhileStream extends _ForwardingStream$(T, T) {
3961 _TakeWhileStream(source, test) { 4044 _TakeWhileStream(source, test) {
3962 this[_test] = test; 4045 this[_test] = test;
3963 super._ForwardingStream(source); 4046 super._ForwardingStream(source);
3964 } 4047 }
3965 [_handleData](inputEvent, sink) { 4048 [_handleData](inputEvent, sink) {
4049 dart.as(inputEvent, T);
4050 dart.as(sink, _EventSink$(T));
3966 let satisfies = null; 4051 let satisfies = null;
3967 try { 4052 try {
3968 satisfies = this[_test](inputEvent); 4053 satisfies = this[_test](inputEvent);
3969 } catch (e) { 4054 } catch (e) {
3970 let s = dart.stackTrace(e); 4055 let s = dart.stackTrace(e);
3971 _addErrorWithReplacement(sink, e, s); 4056 _addErrorWithReplacement(sink, e, s);
3972 sink[_close](); 4057 sink[_close]();
3973 return; 4058 return;
3974 } 4059 }
3975 4060
3976 if (satisfies) { 4061 if (satisfies) {
3977 sink[_add](inputEvent); 4062 sink[_add](inputEvent);
3978 } else { 4063 } else {
3979 sink[_close](); 4064 sink[_close]();
3980 } 4065 }
3981 } 4066 }
3982 } 4067 }
3983 return _TakeWhileStream; 4068 return _TakeWhileStream;
3984 }); 4069 });
3985 let _TakeWhileStream = _TakeWhileStream$(); 4070 let _TakeWhileStream = _TakeWhileStream$();
3986 let _SkipStream$ = dart.generic(function(T) { 4071 let _SkipStream$ = dart.generic(function(T) {
3987 class _SkipStream extends _ForwardingStream$(T, T) { 4072 class _SkipStream extends _ForwardingStream$(T, T) {
3988 _SkipStream(source, count) { 4073 _SkipStream(source, count) {
3989 this[_remaining] = count; 4074 this[_remaining] = count;
3990 super._ForwardingStream(source); 4075 super._ForwardingStream(source);
3991 if (!(typeof count == 'number') || dart.notNull(count) < 0) 4076 if (!(typeof count == 'number') || dart.notNull(count) < 0)
3992 throw new core.ArgumentError(count); 4077 throw new core.ArgumentError(count);
3993 } 4078 }
3994 [_handleData](inputEvent, sink) { 4079 [_handleData](inputEvent, sink) {
4080 dart.as(inputEvent, T);
4081 dart.as(sink, _EventSink$(T));
3995 if (dart.notNull(this[_remaining]) > 0) { 4082 if (dart.notNull(this[_remaining]) > 0) {
3996 this[_remaining] = dart.notNull(this[_remaining]) - 1; 4083 this[_remaining] = dart.notNull(this[_remaining]) - 1;
3997 return; 4084 return;
3998 } 4085 }
3999 sink[_add](inputEvent); 4086 sink[_add](inputEvent);
4000 } 4087 }
4001 } 4088 }
4002 return _SkipStream; 4089 return _SkipStream;
4003 }); 4090 });
4004 let _SkipStream = _SkipStream$(); 4091 let _SkipStream = _SkipStream$();
4005 let _hasFailed = Symbol('_hasFailed'); 4092 let _hasFailed = Symbol('_hasFailed');
4006 let _SkipWhileStream$ = dart.generic(function(T) { 4093 let _SkipWhileStream$ = dart.generic(function(T) {
4007 class _SkipWhileStream extends _ForwardingStream$(T, T) { 4094 class _SkipWhileStream extends _ForwardingStream$(T, T) {
4008 _SkipWhileStream(source, test) { 4095 _SkipWhileStream(source, test) {
4009 this[_test] = test; 4096 this[_test] = test;
4010 this[_hasFailed] = false; 4097 this[_hasFailed] = false;
4011 super._ForwardingStream(source); 4098 super._ForwardingStream(source);
4012 } 4099 }
4013 [_handleData](inputEvent, sink) { 4100 [_handleData](inputEvent, sink) {
4101 dart.as(inputEvent, T);
4102 dart.as(sink, _EventSink$(T));
4014 if (this[_hasFailed]) { 4103 if (this[_hasFailed]) {
4015 sink[_add](inputEvent); 4104 sink[_add](inputEvent);
4016 return; 4105 return;
4017 } 4106 }
4018 let satisfies = null; 4107 let satisfies = null;
4019 try { 4108 try {
4020 satisfies = this[_test](inputEvent); 4109 satisfies = this[_test](inputEvent);
4021 } catch (e) { 4110 } catch (e) {
4022 let s = dart.stackTrace(e); 4111 let s = dart.stackTrace(e);
4023 _addErrorWithReplacement(sink, e, s); 4112 _addErrorWithReplacement(sink, e, s);
(...skipping 17 matching lines...) Expand all
4041 let _Equality = _Equality$(); 4130 let _Equality = _Equality$();
4042 let _equals = Symbol('_equals'); 4131 let _equals = Symbol('_equals');
4043 let _DistinctStream$ = dart.generic(function(T) { 4132 let _DistinctStream$ = dart.generic(function(T) {
4044 class _DistinctStream extends _ForwardingStream$(T, T) { 4133 class _DistinctStream extends _ForwardingStream$(T, T) {
4045 _DistinctStream(source, equals) { 4134 _DistinctStream(source, equals) {
4046 this[_previous] = _DistinctStream._SENTINEL; 4135 this[_previous] = _DistinctStream._SENTINEL;
4047 this[_equals] = equals; 4136 this[_equals] = equals;
4048 super._ForwardingStream(source); 4137 super._ForwardingStream(source);
4049 } 4138 }
4050 [_handleData](inputEvent, sink) { 4139 [_handleData](inputEvent, sink) {
4140 dart.as(inputEvent, T);
4141 dart.as(sink, _EventSink$(T));
4051 if (core.identical(this[_previous], _DistinctStream._SENTINEL)) { 4142 if (core.identical(this[_previous], _DistinctStream._SENTINEL)) {
4052 this[_previous] = inputEvent; 4143 this[_previous] = inputEvent;
4053 return sink[_add](inputEvent); 4144 return sink[_add](inputEvent);
4054 } else { 4145 } else {
4055 let isEqual = null; 4146 let isEqual = null;
4056 try { 4147 try {
4057 if (this[_equals] == null) { 4148 if (this[_equals] == null) {
4058 isEqual = dart.equals(this[_previous], inputEvent); 4149 isEqual = dart.equals(this[_previous], inputEvent);
4059 } else { 4150 } else {
4060 isEqual = this[_equals](dart.as(this[_previous], T), inputEvent); 4151 isEqual = this[_equals](dart.as(this[_previous], T), inputEvent);
(...skipping 19 matching lines...) Expand all
4080 }); 4171 });
4081 return _DistinctStream; 4172 return _DistinctStream;
4082 }); 4173 });
4083 let _DistinctStream = _DistinctStream$(); 4174 let _DistinctStream = _DistinctStream$();
4084 let _EventSinkWrapper$ = dart.generic(function(T) { 4175 let _EventSinkWrapper$ = dart.generic(function(T) {
4085 class _EventSinkWrapper extends core.Object { 4176 class _EventSinkWrapper extends core.Object {
4086 _EventSinkWrapper(sink) { 4177 _EventSinkWrapper(sink) {
4087 this[_sink] = sink; 4178 this[_sink] = sink;
4088 } 4179 }
4089 add(data) { 4180 add(data) {
4181 dart.as(data, T);
4090 this[_sink][_add](data); 4182 this[_sink][_add](data);
4091 } 4183 }
4092 addError(error, stackTrace) { 4184 addError(error, stackTrace) {
4093 if (stackTrace === void 0) 4185 if (stackTrace === void 0)
4094 stackTrace = null; 4186 stackTrace = null;
4095 this[_sink][_addError](error, stackTrace); 4187 this[_sink][_addError](error, stackTrace);
4096 } 4188 }
4097 close() { 4189 close() {
4098 this[_sink][_close](); 4190 this[_sink][_close]();
4099 } 4191 }
(...skipping 11 matching lines...) Expand all
4111 this[_subscription] = null; 4203 this[_subscription] = null;
4112 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r); 4204 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r);
4113 let eventSink = new (_EventSinkWrapper$(T))(this); 4205 let eventSink = new (_EventSinkWrapper$(T))(this);
4114 this[_transformerSink] = mapper(eventSink); 4206 this[_transformerSink] = mapper(eventSink);
4115 this[_subscription] = source.listen(this[_handleData].bind(this), {onErr or: this[_handleError].bind(this), onDone: this[_handleDone].bind(this)}); 4207 this[_subscription] = source.listen(this[_handleData].bind(this), {onErr or: this[_handleError].bind(this), onDone: this[_handleDone].bind(this)});
4116 } 4208 }
4117 get [_isSubscribed]() { 4209 get [_isSubscribed]() {
4118 return this[_subscription] != null; 4210 return this[_subscription] != null;
4119 } 4211 }
4120 [_add](data) { 4212 [_add](data) {
4213 dart.as(data, T);
4121 if (this[_isClosed]) { 4214 if (this[_isClosed]) {
4122 throw new core.StateError("Stream is already closed"); 4215 throw new core.StateError("Stream is already closed");
4123 } 4216 }
4124 super[_add](data); 4217 super[_add](data);
4125 } 4218 }
4126 [_addError](error, stackTrace) { 4219 [_addError](error, stackTrace) {
4127 if (this[_isClosed]) { 4220 if (this[_isClosed]) {
4128 throw new core.StateError("Stream is already closed"); 4221 throw new core.StateError("Stream is already closed");
4129 } 4222 }
4130 super[_addError](error, stackTrace); 4223 super[_addError](error, stackTrace);
(...skipping 14 matching lines...) Expand all
4145 } 4238 }
4146 [_onCancel]() { 4239 [_onCancel]() {
4147 if (this[_isSubscribed]) { 4240 if (this[_isSubscribed]) {
4148 let subscription = this[_subscription]; 4241 let subscription = this[_subscription];
4149 this[_subscription] = null; 4242 this[_subscription] = null;
4150 subscription.cancel(); 4243 subscription.cancel();
4151 } 4244 }
4152 return null; 4245 return null;
4153 } 4246 }
4154 [_handleData](data) { 4247 [_handleData](data) {
4248 dart.as(data, S);
4155 try { 4249 try {
4156 this[_transformerSink].add(data); 4250 this[_transformerSink].add(data);
4157 } catch (e) { 4251 } catch (e) {
4158 let s = dart.stackTrace(e); 4252 let s = dart.stackTrace(e);
4159 this[_addError](e, s); 4253 this[_addError](e, s);
4160 } 4254 }
4161 4255
4162 } 4256 }
4163 [_handleError](error, stackTrace) { 4257 [_handleError](error, stackTrace) {
4164 if (stackTrace === void 0) 4258 if (stackTrace === void 0)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 class _BoundSinkStream extends Stream$(T) { 4306 class _BoundSinkStream extends Stream$(T) {
4213 get isBroadcast() { 4307 get isBroadcast() {
4214 return this[_stream].isBroadcast; 4308 return this[_stream].isBroadcast;
4215 } 4309 }
4216 _BoundSinkStream(stream, sinkMapper) { 4310 _BoundSinkStream(stream, sinkMapper) {
4217 this[_stream] = stream; 4311 this[_stream] = stream;
4218 this[_sinkMapper] = sinkMapper; 4312 this[_sinkMapper] = sinkMapper;
4219 super.Stream(); 4313 super.Stream();
4220 } 4314 }
4221 listen(onData, opts) { 4315 listen(onData, opts) {
4316 dart.as(onData, dart.functionType(dart.void, [T]));
4222 let onError = opts && 'onError' in opts ? opts.onError : null; 4317 let onError = opts && 'onError' in opts ? opts.onError : null;
4223 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 4318 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
4319 dart.as(onDone, dart.functionType(dart.void, []));
4224 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 4320 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
4225 cancelOnError = core.identical(true, cancelOnError); 4321 cancelOnError = core.identical(true, cancelOnError);
4226 let subscription = new _SinkTransformerStreamSubscription(this[_stream], dart.as(this[_sinkMapper], _SinkMapper), onData, onError, onDone, cancelOnError ); 4322 let subscription = new _SinkTransformerStreamSubscription(this[_stream], dart.as(this[_sinkMapper], _SinkMapper), onData, onError, onDone, cancelOnError );
4227 return subscription; 4323 return subscription;
4228 } 4324 }
4229 } 4325 }
4230 return _BoundSinkStream; 4326 return _BoundSinkStream;
4231 }); 4327 });
4232 let _BoundSinkStream = _BoundSinkStream$(); 4328 let _BoundSinkStream = _BoundSinkStream$();
4233 let _TransformDataHandler$ = dart.generic(function(S, T) { 4329 let _TransformDataHandler$ = dart.generic(function(S, T) {
(...skipping 13 matching lines...) Expand all
4247 let _TransformDoneHandler = _TransformDoneHandler$(); 4343 let _TransformDoneHandler = _TransformDoneHandler$();
4248 let _HandlerEventSink$ = dart.generic(function(S, T) { 4344 let _HandlerEventSink$ = dart.generic(function(S, T) {
4249 class _HandlerEventSink extends core.Object { 4345 class _HandlerEventSink extends core.Object {
4250 _HandlerEventSink(handleData, handleError, handleDone, sink) { 4346 _HandlerEventSink(handleData, handleError, handleDone, sink) {
4251 this[_handleData] = handleData; 4347 this[_handleData] = handleData;
4252 this[_handleError] = handleError; 4348 this[_handleError] = handleError;
4253 this[_handleDone] = handleDone; 4349 this[_handleDone] = handleDone;
4254 this[_sink] = sink; 4350 this[_sink] = sink;
4255 } 4351 }
4256 add(data) { 4352 add(data) {
4353 dart.as(data, S);
4257 return this[_handleData](data, this[_sink]); 4354 return this[_handleData](data, this[_sink]);
4258 } 4355 }
4259 addError(error, stackTrace) { 4356 addError(error, stackTrace) {
4260 if (stackTrace === void 0) 4357 if (stackTrace === void 0)
4261 stackTrace = null; 4358 stackTrace = null;
4262 return this[_handleError](error, stackTrace, this[_sink]); 4359 return this[_handleError](error, stackTrace, this[_sink]);
4263 } 4360 }
4264 close() { 4361 close() {
4265 return this[_handleDone](this[_sink]); 4362 return this[_handleDone](this[_sink]);
4266 } 4363 }
4267 } 4364 }
4268 _HandlerEventSink[dart.implements] = () => [EventSink$(S)]; 4365 _HandlerEventSink[dart.implements] = () => [EventSink$(S)];
4269 return _HandlerEventSink; 4366 return _HandlerEventSink;
4270 }); 4367 });
4271 let _HandlerEventSink = _HandlerEventSink$(); 4368 let _HandlerEventSink = _HandlerEventSink$();
4272 let _StreamHandlerTransformer$ = dart.generic(function(S, T) { 4369 let _StreamHandlerTransformer$ = dart.generic(function(S, T) {
4273 class _StreamHandlerTransformer extends _StreamSinkTransformer$(S, T) { 4370 class _StreamHandlerTransformer extends _StreamSinkTransformer$(S, T) {
4274 _StreamHandlerTransformer(opts) { 4371 _StreamHandlerTransformer(opts) {
4275 let handleData = opts && 'handleData' in opts ? opts.handleData : null; 4372 let handleData = opts && 'handleData' in opts ? opts.handleData : null;
4373 dart.as(handleData, dart.functionType(dart.void, [S, EventSink$(T)]));
4276 let handleError = opts && 'handleError' in opts ? opts.handleError : nul l; 4374 let handleError = opts && 'handleError' in opts ? opts.handleError : nul l;
4375 dart.as(handleError, dart.functionType(dart.void, [core.Object, core.Sta ckTrace, EventSink$(T)]));
4277 let handleDone = opts && 'handleDone' in opts ? opts.handleDone : null; 4376 let handleDone = opts && 'handleDone' in opts ? opts.handleDone : null;
4377 dart.as(handleDone, dart.functionType(dart.void, [EventSink$(T)]));
4278 super._StreamSinkTransformer(dart.as(outputSink => { 4378 super._StreamSinkTransformer(dart.as(outputSink => {
4279 if (handleData == null) 4379 if (handleData == null)
4280 handleData = dart.as(_StreamHandlerTransformer._defaultHandleData, _ _CastType29); 4380 handleData = dart.as(_StreamHandlerTransformer._defaultHandleData, _ _CastType29);
4281 if (handleError == null) 4381 if (handleError == null)
4282 handleError = dart.as(_StreamHandlerTransformer._defaultHandleError, __CastType32); 4382 handleError = dart.as(_StreamHandlerTransformer._defaultHandleError, __CastType32);
4283 if (handleDone == null) 4383 if (handleDone == null)
4284 handleDone = _StreamHandlerTransformer._defaultHandleDone; 4384 handleDone = _StreamHandlerTransformer._defaultHandleDone;
4285 return new (_HandlerEventSink$(S, T))(handleData, handleError, handleD one, outputSink); 4385 return new (_HandlerEventSink$(S, T))(handleData, handleError, handleD one, outputSink);
4286 }, _SinkMapper$(S, T))); 4386 }, _SinkMapper$(S, T)));
4287 } 4387 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 }); 4421 });
4322 let _StreamSubscriptionTransformer = _StreamSubscriptionTransformer$(); 4422 let _StreamSubscriptionTransformer = _StreamSubscriptionTransformer$();
4323 let _BoundSubscriptionStream$ = dart.generic(function(S, T) { 4423 let _BoundSubscriptionStream$ = dart.generic(function(S, T) {
4324 class _BoundSubscriptionStream extends Stream$(T) { 4424 class _BoundSubscriptionStream extends Stream$(T) {
4325 _BoundSubscriptionStream(stream, transformer) { 4425 _BoundSubscriptionStream(stream, transformer) {
4326 this[_stream] = stream; 4426 this[_stream] = stream;
4327 this[_transformer] = transformer; 4427 this[_transformer] = transformer;
4328 super.Stream(); 4428 super.Stream();
4329 } 4429 }
4330 listen(onData, opts) { 4430 listen(onData, opts) {
4431 dart.as(onData, dart.functionType(dart.void, [T]));
4331 let onError = opts && 'onError' in opts ? opts.onError : null; 4432 let onError = opts && 'onError' in opts ? opts.onError : null;
4332 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 4433 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
4434 dart.as(onDone, dart.functionType(dart.void, []));
4333 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 4435 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
4334 cancelOnError = core.identical(true, cancelOnError); 4436 cancelOnError = core.identical(true, cancelOnError);
4335 let result = this[_transformer](this[_stream], cancelOnError); 4437 let result = this[_transformer](this[_stream], cancelOnError);
4336 result.onData(onData); 4438 result.onData(onData);
4337 result.onError(onError); 4439 result.onError(onError);
4338 result.onDone(onDone); 4440 result.onDone(onDone);
4339 return result; 4441 return result;
4340 } 4442 }
4341 } 4443 }
4342 return _BoundSubscriptionStream; 4444 return _BoundSubscriptionStream;
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
5200 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; 5302 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5201 exports.CreateTimerHandler = CreateTimerHandler; 5303 exports.CreateTimerHandler = CreateTimerHandler;
5202 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; 5304 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5203 exports.PrintHandler = PrintHandler; 5305 exports.PrintHandler = PrintHandler;
5204 exports.ForkHandler = ForkHandler; 5306 exports.ForkHandler = ForkHandler;
5205 exports.ZoneSpecification = ZoneSpecification; 5307 exports.ZoneSpecification = ZoneSpecification;
5206 exports.ZoneDelegate = ZoneDelegate; 5308 exports.ZoneDelegate = ZoneDelegate;
5207 exports.Zone = Zone; 5309 exports.Zone = Zone;
5208 exports.runZoned = runZoned; 5310 exports.runZoned = runZoned;
5209 })(async || (async = {})); 5311 })(async || (async = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698