Skip to content

Commit 9f4769f

Browse files
sigmundchcommit-bot@chromium.org
authored andcommitted
[ddc] Add back nullcheck in js_array
Change-Id: I9c32705b97c54b47f03898f0d007a3f07b13e465 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135358 Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Sigmund Cherem <sigmund@google.com>
1 parent fa74c54 commit 9f4769f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sdk_nnbd/lib/_internal/js_dev_runtime/private/js_array.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ class JSArray<E> implements List<E>, JSIndexable<E> {
552552

553553
E operator [](int index) {
554554
// Suppress redundant null checks via JS.
555-
if (JS<int>('!', '#', index) >= JS<int>('!', '#.length', this) ||
555+
if (index == null ||
556+
JS<int>('!', '#', index) >= JS<int>('!', '#.length', this) ||
556557
JS<int>('!', '#', index) < 0) {
557558
throw diagnoseIndexError(this, index);
558559
}
@@ -561,7 +562,8 @@ class JSArray<E> implements List<E>, JSIndexable<E> {
561562

562563
void operator []=(int index, E value) {
563564
checkMutable('indexed set');
564-
if (JS<int>('!', '#', index) >= JS<int>('!', '#.length', this) ||
565+
if (index == null ||
566+
JS<int>('!', '#', index) >= JS<int>('!', '#.length', this) ||
565567
JS<int>('!', '#', index) < 0) {
566568
throw diagnoseIndexError(this, index);
567569
}

0 commit comments

Comments
 (0)