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

Side by Side Diff: lib/src/stream_sink_transformer/handler_transformer.dart

Issue 1841223002: Fix most strong mode warnings. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 8 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
« no previous file with comments | « lib/src/stream_sink_completer.dart ('k') | lib/src/stream_splitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../stream_sink_transformer.dart'; 7 import '../stream_sink_transformer.dart';
8 import '../delegate/stream_sink.dart'; 8 import '../delegate/stream_sink.dart';
9 9
10 /// The type of the callback for handling data events. 10 /// The type of the callback for handling data events.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 final StreamSink<T> _safeCloseInner; 47 final StreamSink<T> _safeCloseInner;
48 48
49 Future get done => _inner.done; 49 Future get done => _inner.done;
50 50
51 _HandlerSink(this._transformer, StreamSink<T> inner) 51 _HandlerSink(this._transformer, StreamSink<T> inner)
52 : _inner = inner, 52 : _inner = inner,
53 _safeCloseInner = new _SafeCloseSink<T>(inner); 53 _safeCloseInner = new _SafeCloseSink<T>(inner);
54 54
55 void add(S event) { 55 void add(S event) {
56 if (_transformer._handleData == null) { 56 if (_transformer._handleData == null) {
57 // [event] is an S and [_inner.add] takes a T. This style of conversion 57 _inner.add(event as T);
58 // will throw an error in checked mode if [_inner] is actually a
59 // [StreamSink<T>], but will work if [_inner] isn't reified and won't add
60 // an extra check in unchecked mode.
61 _inner.add(event as dynamic);
62 } else { 58 } else {
63 _transformer._handleData(event, _safeCloseInner); 59 _transformer._handleData(event, _safeCloseInner);
64 } 60 }
65 } 61 }
66 62
67 void addError(error, [StackTrace stackTrace]) { 63 void addError(error, [StackTrace stackTrace]) {
68 if (_transformer._handleError == null) { 64 if (_transformer._handleError == null) {
69 _inner.addError(error, stackTrace); 65 _inner.addError(error, stackTrace);
70 } else { 66 } else {
71 _transformer._handleError(error, stackTrace, _safeCloseInner); 67 _transformer._handleError(error, stackTrace, _safeCloseInner);
(...skipping 24 matching lines...) Expand all
96 class _SafeCloseSink<T> extends DelegatingStreamSink<T> { 92 class _SafeCloseSink<T> extends DelegatingStreamSink<T> {
97 _SafeCloseSink(StreamSink<T> inner) : super(inner); 93 _SafeCloseSink(StreamSink<T> inner) : super(inner);
98 94
99 Future close() => super.close().catchError((_) {}); 95 Future close() => super.close().catchError((_) {});
100 } 96 }
101 97
102 /// A function to pass as a [StreamTransformer]'s `handleDone` callback. 98 /// A function to pass as a [StreamTransformer]'s `handleDone` callback.
103 void _closeSink(EventSink sink) { 99 void _closeSink(EventSink sink) {
104 sink.close(); 100 sink.close();
105 } 101 }
OLDNEW
« no previous file with comments | « lib/src/stream_sink_completer.dart ('k') | lib/src/stream_splitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698