Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Unified Diff: sdk/lib/collection/list.dart

Issue 1146163004: Fix typo in ListMixin.insertAll. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/list.dart
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index e7d902ece79cc6220c7f998359313b214eed8b1b..9b6b753a815db1dd3f729e54e021322f743bfc58 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -476,7 +476,7 @@ abstract class ListMixin<E> implements List<E> {
void insertAll(int index, Iterable<E> iterable) {
RangeError.checkValueInInterval(index, 0, length, "index");
- if (iterable is EfficientLength) {
+ if (iterable is! EfficientLength || identical(iterable, this)) {
Søren Gjesse 2015/06/01 11:37:57 Are these cased covered by tests? I guess that we
Lasse Reichstein Nielsen 2015/06/01 13:13:10 Probably not. It's hard to test because it only af
iterable = iterable.toList();
}
int insertionLength = iterable.length;
@@ -484,6 +484,12 @@ abstract class ListMixin<E> implements List<E> {
// will end up being modified but the operation not complete. Unless we
// always go through a "toList" we can't really avoid that.
this.length += insertionLength;
+ if (iterable.length != insertionLength) {
+ // If the iterable's length is linked to this list's length somehow,
+ // we can't insert one in the other.
+ this.length -= insertionLength;
+ throw new ConcurrentModificationError(iterable);
+ }
setRange(index + insertionLength, this.length, this, index);
setAll(index, iterable);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698