mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Make CastStreamSubscription.onData handle a null callback
Fixes #33166 Change-Id: I52e8bcb6c782c84e8a474b0fc40ada24f31bf602 Reviewed-on: https://dart-review.googlesource.com/55984 Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
2a8eb8089d
commit
580e486386
|
@ -32,7 +32,8 @@ class CastStreamSubscription<S, T> implements StreamSubscription<T> {
|
|||
Future cancel() => _source.cancel();
|
||||
|
||||
void onData(void handleData(T data)) {
|
||||
_source.onData((S data) => handleData(data as T));
|
||||
_source
|
||||
.onData(handleData == null ? null : (S data) => handleData(data as T));
|
||||
}
|
||||
|
||||
void onError(Function handleError) {
|
||||
|
|
12
tests/corelib_2/regress_33166_test.dart
Normal file
12
tests/corelib_2/regress_33166_test.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/33166
|
||||
void main() async {
|
||||
var stream = new Stream.fromIterable([1, 2, 3]);
|
||||
Expect.equals(await stream.cast<int>().drain().then((_) => 'Done'), 'Done');
|
||||
}
|
Loading…
Reference in a new issue