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

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

Issue 1010893004: Allow S->T <: dynamic->T (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Add comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 part of dart.async; 1 part of dart.async;
2 abstract class StreamController<T> implements StreamSink<T> {Stream<T> get stre am; 2 abstract class StreamController<T> implements StreamSink<T> {Stream<T> get stre am;
3 factory StreamController({ 3 factory StreamController({
4 void onListen(), void onPause(), void onResume(), onCancel(), bool sync : fals e} 4 void onListen(), void onPause(), void onResume(), onCancel(), bool sync : fals e}
5 ) { 5 ) {
6 if (onListen == null && onPause == null && onResume == null && onCancel == nul l) { 6 if (onListen == null && onPause == null && onResume == null && onCancel == nul l) {
7 return ((__x106) => DEVC$RT.cast(__x106, DEVC$RT.type((_StreamController<dyn amic> _) { 7 return ((__x82) => DEVC$RT.cast(__x82, DEVC$RT.type((_StreamController<dynam ic> _) {
8 } 8 }
9 ), DEVC$RT.type((StreamController<T> _) { 9 ), DEVC$RT.type((StreamController<T> _) {
10 } 10 }
11 ), "CastDynamic", """line 83, column 14 of dart:async/stream_controller.dart : """, __x106 is StreamController<T>, false))(sync ? new _NoCallbackSyncStreamCo ntroller() : new _NoCallbackAsyncStreamController()); 11 ), "CastDynamic", """line 83, column 14 of dart:async/stream_controller.dart : """, __x82 is StreamController<T>, false))(sync ? new _NoCallbackSyncStreamCon troller() : new _NoCallbackAsyncStreamController());
12 } 12 }
13 return sync ? new _SyncStreamController<T>(onListen, onPause, onResume, onCan cel) : new _AsyncStreamController<T>(onListen, onPause, onResume, onCancel); 13 return sync ? new _SyncStreamController<T>(onListen, onPause, onResume, onCan cel) : new _AsyncStreamController<T>(onListen, onPause, onResume, onCancel);
14 } 14 }
15 factory StreamController.broadcast({ 15 factory StreamController.broadcast({
16 void onListen(), void onCancel(), bool sync : false} 16 void onListen(), void onCancel(), bool sync : false}
17 ) { 17 ) {
18 return sync ? new _SyncBroadcastStreamController<T>(onListen, onCancel) : new _AsyncBroadcastStreamController<T>(onListen, onCancel); 18 return sync ? new _SyncBroadcastStreamController<T>(onListen, onCancel) : new _AsyncBroadcastStreamController<T>(onListen, onCancel);
19 } 19 }
20 StreamSink<T> get sink; 20 StreamSink<T> get sink;
21 bool get isClosed; 21 bool get isClosed;
(...skipping 18 matching lines...) Expand all
40 static const int _STATE_CLOSED = 4; 40 static const int _STATE_CLOSED = 4;
41 static const int _STATE_ADDSTREAM = 8; 41 static const int _STATE_ADDSTREAM = 8;
42 var _varData; 42 var _varData;
43 int _state = _STATE_INITIAL; 43 int _state = _STATE_INITIAL;
44 _Future _doneFuture; 44 _Future _doneFuture;
45 _StreamController(); 45 _StreamController();
46 _NotificationHandler get _onListen; 46 _NotificationHandler get _onListen;
47 _NotificationHandler get _onPause; 47 _NotificationHandler get _onPause;
48 _NotificationHandler get _onResume; 48 _NotificationHandler get _onResume;
49 _NotificationHandler get _onCancel; 49 _NotificationHandler get _onCancel;
50 Stream<T> get stream => ((__x107) => DEVC$RT.cast(__x107, DEVC$RT.type((_Contro llerStream<dynamic> _) { 50 Stream<T> get stream => ((__x83) => DEVC$RT.cast(__x83, DEVC$RT.type((_Controll erStream<dynamic> _) {
51 } 51 }
52 ), DEVC$RT.type((Stream<T> _) { 52 ), DEVC$RT.type((Stream<T> _) {
53 } 53 }
54 ), "CastExact", """line 293, column 27 of dart:async/stream_controller.dart: """ , __x107 is Stream<T>, false))(new _ControllerStream(this)); 54 ), "CastExact", """line 293, column 27 of dart:async/stream_controller.dart: """ , __x83 is Stream<T>, false))(new _ControllerStream(this));
55 StreamSink<T> get sink => new _StreamSinkWrapper<T>(this); 55 StreamSink<T> get sink => new _StreamSinkWrapper<T>(this);
56 bool get _isCanceled => (_state & _STATE_CANCELED) != 0; 56 bool get _isCanceled => (_state & _STATE_CANCELED) != 0;
57 bool get hasListener => (_state & _STATE_SUBSCRIBED) != 0; 57 bool get hasListener => (_state & _STATE_SUBSCRIBED) != 0;
58 bool get _isInitialState => (_state & _STATE_SUBSCRIPTION_MASK) == _STATE_INITI AL; 58 bool get _isInitialState => (_state & _STATE_SUBSCRIPTION_MASK) == _STATE_INITI AL;
59 bool get isClosed => (_state & _STATE_CLOSED) != 0; 59 bool get isClosed => (_state & _STATE_CLOSED) != 0;
60 bool get isPaused => hasListener ? _subscription._isInputPaused : !_isCanceled; 60 bool get isPaused => hasListener ? _subscription._isInputPaused : !_isCanceled;
61 bool get _isAddingStream => (_state & _STATE_ADDSTREAM) != 0; 61 bool get _isAddingStream => (_state & _STATE_ADDSTREAM) != 0;
62 bool get _mayAddEvent => (_state < _STATE_CLOSED); 62 bool get _mayAddEvent => (_state < _STATE_CLOSED);
63 _PendingEvents get _pendingEvents { 63 _PendingEvents get _pendingEvents {
64 assert (_isInitialState); if (!_isAddingStream) { 64 assert (_isInitialState); if (!_isAddingStream) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 ), "CastGeneral", """line 482, column 48 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true); 169 ), "CastGeneral", """line 482, column 48 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true);
170 _varData = addState.varData; 170 _varData = addState.varData;
171 _state &= ~_STATE_ADDSTREAM; 171 _state &= ~_STATE_ADDSTREAM;
172 addState.complete(); 172 addState.complete();
173 } 173 }
174 StreamSubscription<T> _subscribe(void onData(T data), Function onError, void on Done(), bool cancelOnError) { 174 StreamSubscription<T> _subscribe(void onData(T data), Function onError, void on Done(), bool cancelOnError) {
175 if (!_isInitialState) { 175 if (!_isInitialState) {
176 throw new StateError("Stream has already been listened to."); 176 throw new StateError("Stream has already been listened to.");
177 } 177 }
178 _ControllerSubscription subscription = new _ControllerSubscription(this, DEVC$R T.wrap((void f(T __u108)) { 178 _ControllerSubscription subscription = new _ControllerSubscription(this, onData , onError, onDone, cancelOnError);
179 void c(T x0) => f(DEVC$RT.cast(x0, dynamic, T, "CastParam", """line 499, column 43 of dart:async/stream_controller.dart: """, x0 is T, false));
180 return f == null ? null : c;
181 }
182 , onData, DEVC$RT.type((__t111<T> _) {
183 }
184 ), __t109, "Wrap", """line 499, column 43 of dart:async/stream_controller.dart: """, onData is __t109), onError, onDone, cancelOnError);
185 _PendingEvents pendingEvents = _pendingEvents; 179 _PendingEvents pendingEvents = _pendingEvents;
186 _state |= _STATE_SUBSCRIBED; 180 _state |= _STATE_SUBSCRIBED;
187 if (_isAddingStream) { 181 if (_isAddingStream) {
188 _StreamControllerAddStreamState addState = DEVC$RT.cast(_varData, dynamic, DEVC$ RT.type((_StreamControllerAddStreamState<dynamic> _) { 182 _StreamControllerAddStreamState addState = DEVC$RT.cast(_varData, dynamic, DEVC$ RT.type((_StreamControllerAddStreamState<dynamic> _) {
189 } 183 }
190 ), "CastGeneral", """line 505, column 50 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true); 184 ), "CastGeneral", """line 505, column 50 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true);
191 addState.varData = subscription; 185 addState.varData = subscription;
192 addState.resume(); 186 addState.resume();
193 } 187 }
194 else { 188 else {
(...skipping 16 matching lines...) Expand all
211 _StreamControllerAddStreamState addState = DEVC$RT.cast(_varData, dynamic, DEVC$ RT.type((_StreamControllerAddStreamState<dynamic> _) { 205 _StreamControllerAddStreamState addState = DEVC$RT.cast(_varData, dynamic, DEVC$ RT.type((_StreamControllerAddStreamState<dynamic> _) {
212 } 206 }
213 ), "CastGeneral", """line 530, column 50 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true); 207 ), "CastGeneral", """line 530, column 50 of dart:async/stream_controller.dart: " "", _varData is _StreamControllerAddStreamState<dynamic>, true);
214 result = addState.cancel(); 208 result = addState.cancel();
215 } 209 }
216 _varData = null; 210 _varData = null;
217 _state = (_state & ~(_STATE_SUBSCRIBED | _STATE_ADDSTREAM)) | _STATE_CANCELED; 211 _state = (_state & ~(_STATE_SUBSCRIBED | _STATE_ADDSTREAM)) | _STATE_CANCELED;
218 if (_onCancel != null) { 212 if (_onCancel != null) {
219 if (result == null) { 213 if (result == null) {
220 try { 214 try {
221 result = ((__x113) => DEVC$RT.cast(__x113, dynamic, DEVC$RT.type((Future<dyn amic> _) { 215 result = ((__x84) => DEVC$RT.cast(__x84, dynamic, DEVC$RT.type((Future<dynam ic> _) {
222 } 216 }
223 ), "CastGeneral", """line 542, column 20 of dart:async/stream_controller.dar t: """, __x113 is Future<dynamic>, true))(_onCancel()); 217 ), "CastGeneral", """line 542, column 20 of dart:async/stream_controller.dar t: """, __x84 is Future<dynamic>, true))(_onCancel());
224 } 218 }
225 catch (e, s) { 219 catch (e, s) {
226 result = new _Future().._asyncCompleteError(e, s); 220 result = new _Future().._asyncCompleteError(e, s);
227 } 221 }
228 } 222 }
229 else { 223 else {
230 result = result.whenComplete(_onCancel); 224 result = result.whenComplete(_onCancel);
231 } 225 }
232 } 226 }
233 void complete() { 227 void complete() {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 _target.addError(error, stackTrace); 343 _target.addError(error, stackTrace);
350 } 344 }
351 Future close() => _target.close(); 345 Future close() => _target.close();
352 Future addStream(Stream<T> source, { 346 Future addStream(Stream<T> source, {
353 bool cancelOnError : true} 347 bool cancelOnError : true}
354 ) => _target.addStream(source, cancelOnError: cancelOnError); 348 ) => _target.addStream(source, cancelOnError: cancelOnError);
355 Future get done => _target.done; 349 Future get done => _target.done;
356 } 350 }
357 class _AddStreamState<T> {final _Future addStreamFuture; 351 class _AddStreamState<T> {final _Future addStreamFuture;
358 final StreamSubscription addSubscription; 352 final StreamSubscription addSubscription;
359 _AddStreamState(_EventSink<T> controller, Stream source, bool cancelOnError) : addStreamFuture = new _Future(), addSubscription = source.listen(DEVC$RT.wrap((v oid f(T __u114)) { 353 _AddStreamState(_EventSink<T> controller, Stream source, bool cancelOnError) : addStreamFuture = new _Future(), addSubscription = source.listen(controller._add , onError: ((__x85) => DEVC$RT.cast(__x85, dynamic, Function, "CastGeneral", """ line 746, column 50 of dart:async/stream_controller.dart: """, __x85 is Function , true))(cancelOnError ? makeErrorHandler(controller) : controller._addError), o nDone: controller._close, cancelOnError: cancelOnError);
360 void c(T x0) => f(DEVC$RT.cast(x0, dynamic, T, "CastParam", """line 745, column 41 of dart:async/stream_controller.dart: """, x0 is T, false));
361 return f == null ? null : c;
362 }
363 , controller._add, DEVC$RT.type((__t115<T> _) {
364 }
365 ), __t109, "Wrap", """line 745, column 41 of dart:async/stream_controller.dart: """, controller._add is __t109), onError: ((__x117) => DEVC$RT.cast(__x117, dyna mic, Function, "CastGeneral", """line 746, column 50 of dart:async/stream_contro ller.dart: """, __x117 is Function, true))(cancelOnError ? makeErrorHandler(cont roller) : controller._addError), onDone: controller._close, cancelOnError: cance lOnError);
366 static makeErrorHandler(_EventSink controller) => (e, StackTrace s) { 354 static makeErrorHandler(_EventSink controller) => (e, StackTrace s) {
367 controller._addError(e, s); 355 controller._addError(e, s);
368 controller._close(); 356 controller._close();
369 } 357 }
370 ; 358 ;
371 void pause() { 359 void pause() {
372 addSubscription.pause(); 360 addSubscription.pause();
373 } 361 }
374 void resume() { 362 void resume() {
375 addSubscription.resume(); 363 addSubscription.resume();
(...skipping 17 matching lines...) Expand all
393 _StreamControllerAddStreamState(_StreamController controller, this.varData, Str eam source, bool cancelOnError) : super(DEVC$RT.cast(controller, DEVC$RT.type((_ StreamController<dynamic> _) { 381 _StreamControllerAddStreamState(_StreamController controller, this.varData, Str eam source, bool cancelOnError) : super(DEVC$RT.cast(controller, DEVC$RT.type((_ StreamController<dynamic> _) {
394 } 382 }
395 ), DEVC$RT.type((_EventSink<T> _) { 383 ), DEVC$RT.type((_EventSink<T> _) {
396 } 384 }
397 ), "CastDynamic", """line 798, column 15 of dart:async/stream_controller.dart: " "", controller is _EventSink<T>, false), source, cancelOnError) { 385 ), "CastDynamic", """line 798, column 15 of dart:async/stream_controller.dart: " "", controller is _EventSink<T>, false), source, cancelOnError) {
398 if (controller.isPaused) { 386 if (controller.isPaused) {
399 addSubscription.pause(); 387 addSubscription.pause();
400 } 388 }
401 } 389 }
402 } 390 }
403 typedef void __t109(dynamic __u110);
404 typedef void __t111<T>(T __u112);
405 typedef void __t115<T>(T __u116);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698