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

Unified Diff: lib/src/protobuf/pb_list.dart

Issue 1024553002: Fix analyzer warning / bug: Iterable was treated as if it has sublist() (Closed) Base URL: https://github.com/dart-lang/dart-protobuf.git@master
Patch Set: Added test for Iterable with less elements than `end-start` Created 5 years, 9 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 | « CHANGELOG.md ('k') | test/pb_list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/protobuf/pb_list.dart
diff --git a/lib/src/protobuf/pb_list.dart b/lib/src/protobuf/pb_list.dart
index e2b518d5ada4b5764372a73314f1690119342be1..46644e598a6312c8c6737e603f9d0ec8102eecde 100644
--- a/lib/src/protobuf/pb_list.dart
+++ b/lib/src/protobuf/pb_list.dart
@@ -88,7 +88,9 @@ class PbList<E> extends Object with ListMixin<E> implements List<E> {
* not extendable.
*/
void setRange(int start, int end, Iterable<E> from, [int skipCount = 0]) {
- from.sublist(skipCount, skipCount + end - start).forEach(_validate);
+ // NOTE: In case `take()` returns less than `end - start` elements, the
+ // _wrappedList will fail with a `StateError`.
+ from.skip(skipCount).take(end - start).forEach(_validate);
_wrappedList.setRange(start, end, from, skipCount);
}
« no previous file with comments | « CHANGELOG.md ('k') | test/pb_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698