Don't allow null as argument to StreamIterator constructor.

Change-Id: I10c8de2cd12660876908f719ee562006cd3f2c07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98001
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
Lasse R.H. Nielsen 2019-04-30 13:27:48 +00:00 committed by commit-bot@chromium.org
parent 9cf5e51988
commit 1dd0f88c84
4 changed files with 14 additions and 1 deletions

View file

@ -4,6 +4,11 @@
### Core library changes
#### `dart:async`
* BREAKING CHANGE:
Fixes bug in `StreamIterator` which allowed constructor argument to be `null`.
Also allowed `await for` on a `null` stream. This is now a runtime error.
#### `dart:core`
* **Breaking change**: The `RegExp` interface has been extended with two new
@ -27,6 +32,11 @@
This change only affects implementers of the `RegExp` interface; current
code using Dart regular expressions will not be affected.
#### `dart:isolate`
* BREAKING CHANGE: The `await for` allowed `null` as a stream due to a bug
in `StreamIterator` class. This bug has now been fixed.
## 2.3.0
The focus in this release is on the new "UI-as-code" language features which

View file

@ -20,6 +20,7 @@ incomplete_field_formal_parameter: Fail # Fasta doesn't recover well
inference/bug31436: RuntimeError # Test exercises Dart 2.0 semantics
inference/constructors_too_many_positional_arguments: Fail
inference/downwards_inference_annotations_locals: Fail # Issue #30031
inference/downwards_inference_for_each: RuntimeError # Issue #36382
inference/future_then_explicit_future: RuntimeError
inference/generic_methods_infer_js_builtin: RuntimeError # Test attempts to access platform-private library leading to NSM.
inference/infer_assign_to_index: Fail

View file

@ -33,6 +33,7 @@ inference/constructors_infer_from_arguments_argument_not_assignable: TypeCheckEr
inference/constructors_too_many_positional_arguments: InstrumentationMismatch # Issue #30040
inference/do_not_infer_overridden_fields_that_explicitly_say_dynamic_infer: TypeCheckError
inference/downwards_inference_annotations_type_variable: InstrumentationMismatch # Issue 28981
inference/downwards_inference_for_each: RuntimeError # Issue #36382
inference/downwards_inference_on_function_of_t_using_the_t: InstrumentationMismatch # Issue #29798
inference/downwards_inference_on_list_literals_infer_downwards: RuntimeError
inference/future_then_explicit_future: InstrumentationMismatch # Issue #30040

View file

@ -967,7 +967,8 @@ class _StreamIterator<T> implements StreamIterator<T> {
/// completed.
bool _isPaused = false;
_StreamIterator(final Stream<T> stream) : _stateData = stream;
_StreamIterator(final Stream<T> stream)
: _stateData = stream ?? (throw ArgumentError.notNull("stream"));
T get current {
if (_subscription != null && _isPaused) {