[lib] Fix some NNBD lib tests

Fixes:
lib_2/convert/ascii_test
lib_2/convert/latin1_test
lib_2/typed_data/typed_data_list_test
Change-Id: I493ef6e43db71f09e147b21cbaabdf6a47d833de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
This commit is contained in:
Liam Appelbe 2020-02-10 18:06:40 +00:00 committed by commit-bot@chromium.org
parent 721035cd3d
commit b86c6e0ce9
2 changed files with 16 additions and 11 deletions

View file

@ -378,7 +378,9 @@ mixin _IntListMixin implements List<int> {
}
void fillRange(int start, int end, [int? fillValue]) {
if (fillValue == null) throw ArgumentError.notNull("fillValue");
if (fillValue == null && start < end) {
throw ArgumentError.notNull("fillValue");
}
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) {
this[i] = fillValue;
@ -734,7 +736,9 @@ mixin _DoubleListMixin implements List<double> {
void fillRange(int start, int end, [double? fillValue]) {
// TODO(eernst): Could use zero as default and not throw; issue .
if (fillValue == null) throw ArgumentError.notNull("fillValue");
if (fillValue == null && start < end) {
throw ArgumentError.notNull("fillValue");
}
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) {
this[i] = fillValue;
@ -1170,7 +1174,9 @@ abstract class _Float32x4ListMixin implements List<Float32x4> {
}
void fillRange(int start, int end, [Float32x4? fillValue]) {
if (fillValue == null) throw ArgumentError.notNull("fillValue");
if (fillValue == null && start < end) {
throw ArgumentError.notNull("fillValue");
}
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) {
this[i] = fillValue;
@ -1526,7 +1532,9 @@ abstract class _Int32x4ListMixin implements List<Int32x4> {
}
void fillRange(int start, int end, [Int32x4? fillValue]) {
if (fillValue == null) throw ArgumentError.notNull("fillValue");
if (fillValue == null && start < end) {
throw ArgumentError.notNull("fillValue");
}
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) {
this[i] = fillValue;
@ -1883,7 +1891,9 @@ abstract class _Float64x2ListMixin implements List<Float64x2> {
}
void fillRange(int start, int end, [Float64x2? fillValue]) {
if (fillValue == null) throw ArgumentError.notNull("fillValue");
if (fillValue == null && start < end) {
throw ArgumentError.notNull("fillValue");
}
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) {
this[i] = fillValue;

View file

@ -371,12 +371,7 @@ abstract class ListMixin<E> implements List<E> {
if (end == null) throw "!"; // TODO(38493): The `??=` should promote.
RangeError.checkValidRange(start, end, listLength);
int length = end - start;
List<E> result = <E>[]..length = length;
for (int i = 0; i < length; i++) {
result[i] = this[start + i];
}
return result;
return List.from(getRange(start, end));
}
Iterable<E> getRange(int start, int end) {