Chromium Code Reviews| 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); |
| } |