Remove unneeded null check after promotion
Fixes #51171
CoreLibraryReviewExempt: Removes no-longer-needed non-null promotion.
Change-Id: I46215a274c3042619578bf25bff045b15d4e087f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283682
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
diff --git a/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.1.expect b/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.1.expect
index 3ee33183..3a40d93 100644
--- a/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.1.expect
+++ b/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.1.expect
@@ -284,8 +284,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([dart.math::Random? random = #C2]) → void {
random == null ?{dart.math::Random} random = dart.math::Random::•() : null;
- if(random{dart.math::Random} == null)
- throw "!";
dart.core::int length = this.{dart.core::List::length}{dart.core::int};
while (length.{dart.core::num::>}(1){(dart.core::num) → dart.core::bool}) {
dart.core::int pos = random{dart.math::Random}.{dart.math::Random::nextInt}(length){(dart.core::int) → dart.core::int};
@@ -306,8 +304,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(dart.core::int start, [dart.core::int? end = #C2]) → dart.core::List<dart.core::int> {
dart.core::int listLength = this.{dart.core::List::length}{dart.core::int};
end == null ?{dart.core::int} end = listLength : null;
- if(end{dart.core::int} == null)
- throw "!";
dart.core::RangeError::checkValidRange(start, end{dart.core::int}, listLength);
return dart.core::List::from<dart.core::int>(this.{dart.collection::ListBase::getRange}(start, end{dart.core::int}){(dart.core::int, dart.core::int) → dart.core::Iterable<dart.core::int>});
}
@@ -429,8 +425,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class dart.core::Object? element, [dart.core::int? start = #C2]) → dart.core::int {
if(start == null || start{dart.core::int}.{dart.core::num::>=}(this.{dart.core::List::length}{dart.core::int}){(dart.core::num) → dart.core::bool})
start = this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int};
- if(start{dart.core::int} == null)
- throw "!";
for (dart.core::int i = start{dart.core::int}; i.{dart.core::num::>=}(0){(dart.core::num) → dart.core::bool}; i = i.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}) {
if(this.{dart.core::List::[]}(i){(dart.core::int) → dart.core::int} =={dart.core::Object::==}{(dart.core::Object) → dart.core::bool} element)
return i;
@@ -440,8 +434,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((dart.core::int) → dart.core::bool test, [dart.core::int? start = #C2]) → dart.core::int {
if(start == null || start{dart.core::int}.{dart.core::num::>=}(this.{dart.core::List::length}{dart.core::int}){(dart.core::num) → dart.core::bool})
start = this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int};
- if(start{dart.core::int} == null)
- throw "!";
for (dart.core::int i = start{dart.core::int}; i.{dart.core::num::>=}(0){(dart.core::num) → dart.core::bool}; i = i.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}) {
if(test(this.{dart.core::List::[]}(i){(dart.core::int) → dart.core::int}){(dart.core::int) → dart.core::bool})
return i;
diff --git a/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.2.expect b/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.2.expect
index 3ee33183..3a40d93 100644
--- a/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.2.expect
+++ b/pkg/front_end/testcases/incremental/no_outline_change_22.yaml.world.2.expect
@@ -284,8 +284,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([dart.math::Random? random = #C2]) → void {
random == null ?{dart.math::Random} random = dart.math::Random::•() : null;
- if(random{dart.math::Random} == null)
- throw "!";
dart.core::int length = this.{dart.core::List::length}{dart.core::int};
while (length.{dart.core::num::>}(1){(dart.core::num) → dart.core::bool}) {
dart.core::int pos = random{dart.math::Random}.{dart.math::Random::nextInt}(length){(dart.core::int) → dart.core::int};
@@ -306,8 +304,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(dart.core::int start, [dart.core::int? end = #C2]) → dart.core::List<dart.core::int> {
dart.core::int listLength = this.{dart.core::List::length}{dart.core::int};
end == null ?{dart.core::int} end = listLength : null;
- if(end{dart.core::int} == null)
- throw "!";
dart.core::RangeError::checkValidRange(start, end{dart.core::int}, listLength);
return dart.core::List::from<dart.core::int>(this.{dart.collection::ListBase::getRange}(start, end{dart.core::int}){(dart.core::int, dart.core::int) → dart.core::Iterable<dart.core::int>});
}
@@ -429,8 +425,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class dart.core::Object? element, [dart.core::int? start = #C2]) → dart.core::int {
if(start == null || start{dart.core::int}.{dart.core::num::>=}(this.{dart.core::List::length}{dart.core::int}){(dart.core::num) → dart.core::bool})
start = this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int};
- if(start{dart.core::int} == null)
- throw "!";
for (dart.core::int i = start{dart.core::int}; i.{dart.core::num::>=}(0){(dart.core::num) → dart.core::bool}; i = i.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}) {
if(this.{dart.core::List::[]}(i){(dart.core::int) → dart.core::int} =={dart.core::Object::==}{(dart.core::Object) → dart.core::bool} element)
return i;
@@ -440,8 +434,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((dart.core::int) → dart.core::bool test, [dart.core::int? start = #C2]) → dart.core::int {
if(start == null || start{dart.core::int}.{dart.core::num::>=}(this.{dart.core::List::length}{dart.core::int}){(dart.core::num) → dart.core::bool})
start = this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int};
- if(start{dart.core::int} == null)
- throw "!";
for (dart.core::int i = start{dart.core::int}; i.{dart.core::num::>=}(0){(dart.core::num) → dart.core::bool}; i = i.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}) {
if(test(this.{dart.core::List::[]}(i){(dart.core::int) → dart.core::int}){(dart.core::int) → dart.core::bool})
return i;
diff --git a/pkg/front_end/testcases/patterns/cache_lookups.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/cache_lookups.dart.strong.transformed.expect
index 90964c7..ea44fd9 100644
--- a/pkg/front_end/testcases/patterns/cache_lookups.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/cache_lookups.dart.strong.transformed.expect
@@ -359,8 +359,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C5]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -381,8 +379,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C5]) → core::List<cac::_CustomList&Object&ListMixin::E%> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<cac::_CustomList&Object&ListMixin::E%>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<cac::_CustomList&Object&ListMixin::E%>});
}
@@ -504,8 +500,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C5]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → cac::_CustomList&Object&ListMixin::E%} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -515,8 +509,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((cac::_CustomList&Object&ListMixin::E%) → core::bool test, [core::int? start = #C5]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → cac::_CustomList&Object&ListMixin::E%}){(cac::_CustomList&Object&ListMixin::E%) → core::bool})
return i;
@@ -623,8 +615,8 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1166, effectively constant: 4
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 1154, effectively constant: 4
diff --git a/pkg/front_end/testcases/patterns/cache_lookups.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/cache_lookups.dart.weak.transformed.expect
index 0ce369f..4acd139 100644
--- a/pkg/front_end/testcases/patterns/cache_lookups.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/cache_lookups.dart.weak.transformed.expect
@@ -359,8 +359,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C5]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -381,8 +379,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C5]) → core::List<cac::_CustomList&Object&ListMixin::E%> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<cac::_CustomList&Object&ListMixin::E%>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<cac::_CustomList&Object&ListMixin::E%>});
}
@@ -504,8 +500,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C5]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → cac::_CustomList&Object&ListMixin::E%} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -515,8 +509,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((cac::_CustomList&Object&ListMixin::E%) → core::bool test, [core::int? start = #C5]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → cac::_CustomList&Object&ListMixin::E%}){(cac::_CustomList&Object&ListMixin::E%) → core::bool})
return i;
@@ -623,8 +615,8 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1159, effectively constant: 4
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 1147, effectively constant: 4
diff --git a/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.strong.transformed.expect
index a29b8a2..4e37ae4 100644
--- a/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.strong.transformed.expect
@@ -288,8 +288,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C2]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -310,8 +308,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C2]) → core::List<core::int> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<core::int>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<core::int>});
}
@@ -433,8 +429,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → core::int} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -444,8 +438,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((core::int) → core::bool test, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → core::int}){(core::int) → core::bool})
return i;
@@ -571,8 +563,8 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1100, effectively constant: 4
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 1088, effectively constant: 4
diff --git a/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.weak.transformed.expect
index 04e0587..f8122f8 100644
--- a/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/matching_and_capturing_accesses_list_element_once.dart.weak.transformed.expect
@@ -288,8 +288,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C2]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -310,8 +308,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C2]) → core::List<core::int> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<core::int>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<core::int>});
}
@@ -433,8 +429,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → core::int} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -444,8 +438,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((core::int) → core::bool test, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → core::int}){(core::int) → core::bool})
return i;
@@ -571,8 +563,8 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1093, effectively constant: 4
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 1081, effectively constant: 4
diff --git a/pkg/front_end/testcases/patterns/negative_length.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/negative_length.dart.strong.transformed.expect
index c7aaf2b..29b5d81 100644
--- a/pkg/front_end/testcases/patterns/negative_length.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/negative_length.dart.strong.transformed.expect
@@ -288,8 +288,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C2]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -310,8 +308,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C2]) → core::List<self::_NegativeLengthList&Object&ListMixin::E%> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<self::_NegativeLengthList&Object&ListMixin::E%>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<self::_NegativeLengthList&Object&ListMixin::E%>});
}
@@ -433,8 +429,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → self::_NegativeLengthList&Object&ListMixin::E%} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -444,8 +438,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((self::_NegativeLengthList&Object&ListMixin::E%) → core::bool test, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → self::_NegativeLengthList&Object&ListMixin::E%}){(self::_NegativeLengthList&Object&ListMixin::E%) → core::bool})
return i;
@@ -591,9 +583,9 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///negative_length.dart:12:41 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1122, effectively constant: 5
+Extra constant evaluation: evaluated: 1110, effectively constant: 5
diff --git a/pkg/front_end/testcases/patterns/negative_length.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/negative_length.dart.weak.transformed.expect
index d3c97a8..48a9ffa 100644
--- a/pkg/front_end/testcases/patterns/negative_length.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/negative_length.dart.weak.transformed.expect
@@ -288,8 +288,6 @@
}
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ shuffle([math::Random? random = #C2]) → void {
random == null ?{math::Random} random = math::Random::•() : null;
- if(random{math::Random} == null)
- throw "!";
core::int length = this.{core::List::length}{core::int};
while (length.{core::num::>}(1){(core::num) → core::bool}) {
core::int pos = random{math::Random}.{math::Random::nextInt}(length){(core::int) → core::int};
@@ -310,8 +308,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ sublist(core::int start, [core::int? end = #C2]) → core::List<self::_NegativeLengthList&Object&ListMixin::E%> {
core::int listLength = this.{core::List::length}{core::int};
end == null ?{core::int} end = listLength : null;
- if(end{core::int} == null)
- throw "!";
core::RangeError::checkValidRange(start, end{core::int}, listLength);
return core::List::from<self::_NegativeLengthList&Object&ListMixin::E%>(this.{col::ListBase::getRange}(start, end{core::int}){(core::int, core::int) → core::Iterable<self::_NegativeLengthList&Object&ListMixin::E%>});
}
@@ -433,8 +429,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexOf(covariant-by-class core::Object? element, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(this.{core::List::[]}(i){(core::int) → self::_NegativeLengthList&Object&ListMixin::E%} =={core::Object::==}{(core::Object) → core::bool} element)
return i;
@@ -444,8 +438,6 @@
method /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ lastIndexWhere((self::_NegativeLengthList&Object&ListMixin::E%) → core::bool test, [core::int? start = #C2]) → core::int {
if(start == null || start{core::int}.{core::num::>=}(this.{core::List::length}{core::int}){(core::num) → core::bool})
start = this.{core::List::length}{core::int}.{core::num::-}(1){(core::num) → core::int};
- if(start{core::int} == null)
- throw "!";
for (core::int i = start{core::int}; i.{core::num::>=}(0){(core::num) → core::bool}; i = i.{core::num::-}(1){(core::num) → core::int}) {
if(test(this.{core::List::[]}(i){(core::int) → self::_NegativeLengthList&Object&ListMixin::E%}){(self::_NegativeLengthList&Object&ListMixin::E%) → core::bool})
return i;
@@ -592,9 +584,9 @@
}
Extra constant evaluation status:
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:456:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:464:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:476:12 -> IntConstant(-1)
-Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:488:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:454:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:462:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:471:12 -> IntConstant(-1)
+Evaluated: InstanceInvocation @ org-dartlang-sdk:///sdk/lib/collection/list.dart:480:12 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///negative_length.dart:12:41 -> IntConstant(-1)
-Extra constant evaluation: evaluated: 1117, effectively constant: 5
+Extra constant evaluation: evaluated: 1105, effectively constant: 5
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 7781527..61cc4e7 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -327,7 +327,6 @@
void shuffle([Random? random]) {
random ??= Random();
- if (random == null) throw "!"; // TODO(38493): The `??=` should promote.
int length = this.length;
while (length > 1) {
@@ -348,7 +347,6 @@
List<E> sublist(int start, [int? end]) {
int listLength = this.length;
end ??= listLength;
- if (end == null) throw "!"; // TODO(38493): The `??=` should promote.
RangeError.checkValidRange(start, end, listLength);
return List.from(getRange(start, end));
@@ -467,9 +465,6 @@
int lastIndexOf(Object? element, [int? start]) {
if (start == null || start >= this.length) start = this.length - 1;
- // TODO(38493): The previous line should promote.
- if (start == null) throw "!";
-
for (int i = start; i >= 0; i--) {
if (this[i] == element) return i;
}
@@ -479,9 +474,6 @@
int lastIndexWhere(bool test(E element), [int? start]) {
if (start == null || start >= this.length) start = this.length - 1;
- // TODO(38493): The previous line should promote.
- if (start == null) throw "!";
-
for (int i = start; i >= 0; i--) {
if (test(this[i])) return i;
}