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

Unified Diff: runtime/lib/typed_data.dart

Issue 397243002: Make IterableMixinWorkaround using classes return correctly typed Iterables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment, Created 6 years, 5 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 | « runtime/lib/growable_array.dart ('k') | sdk/lib/_internal/lib/js_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/typed_data.dart
diff --git a/runtime/lib/typed_data.dart b/runtime/lib/typed_data.dart
index 0df6950a0a4aecb9ab24a11644f1814df232e740..b8c61682eb5e1fe6f0bfc643bfe7f21ff7767c41 100644
--- a/runtime/lib/typed_data.dart
+++ b/runtime/lib/typed_data.dart
@@ -241,7 +241,7 @@ patch class ByteData {
// Based class for _TypedList that provides common methods for implementing
// the collection and list interfaces.
-
+// TODO(13647): Make this extends ListBase<T>
abstract class _TypedListBase {
// Method(s) implementing the Collection interface.
@@ -254,10 +254,6 @@ abstract class _TypedListBase {
}
}
- Iterable map(f(element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
String join([String separator = ""]) {
return IterableMixinWorkaround.join(this, separator);
}
@@ -271,30 +267,48 @@ abstract class _TypedListBase {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
- Iterable where(bool f(element)) {
- return IterableMixinWorkaround.where(this, f);
+ Iterable map(f(element)) {
+ return IterableMixinWorkaround.mapList(this, f);
}
Iterable expand(Iterable f(element)) {
return IterableMixinWorkaround.expand(this, f);
}
+ // The following methods need to know the element type (int or double).
+ Iterable where(bool f(element)) {
+ return new IterableMixinWorkaround().where(this, f);
+ }
+
Iterable take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
+ return new IterableMixinWorkaround().takeList(this, n);
}
Iterable takeWhile(bool test(element)) {
- return IterableMixinWorkaround.takeWhile(this, test);
+ return new IterableMixinWorkaround().takeWhile(this, test);
}
Iterable skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
+ return new IterableMixinWorkaround().skipList(this, n);
}
Iterable skipWhile(bool test(element)) {
- return IterableMixinWorkaround.skipWhile(this, test);
+ return new IterableMixinWorkaround().skipWhile(this, test);
}
+ Iterable<dynamic> get reversed {
+ return new IterableMixinWorkaround().reversedList(this);
+ }
+
+ Map<int, dynamic> asMap() {
+ return new IterableMixinWorkaround().asMapList(this);
+ }
+
+ Iterable getRange(int start, [int end]) {
+ return new IterableMixinWorkaround().getRangeList(this, start, end);
+ }
+ // End of methods returning incorrectly parameterized types.
+
bool every(bool f(element)) {
return IterableMixinWorkaround.every(this, f);
}
@@ -315,10 +329,6 @@ abstract class _TypedListBase {
return IterableMixinWorkaround.singleWhere(this, test);
}
- Iterable<dynamic> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
dynamic elementAt(int index) {
return this[index];
}
@@ -436,10 +446,6 @@ abstract class _TypedListBase {
return new Set.from(this);
}
- Map<int, dynamic> asMap() {
- return IterableMixinWorkaround.asMapList(this);
- }
-
List sublist(int start, [int end]) {
if (end == null) end = this.length;
int length = end - start;
@@ -449,10 +455,6 @@ abstract class _TypedListBase {
return result;
}
- Iterable getRange(int start, [int end]) {
- return IterableMixinWorkaround.getRangeList(this, start, end);
- }
-
void setRange(int start, int end, Iterable from, [int skipCount = 0]) {
// Check ranges.
if ((start < 0) || (start > length)) {
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | sdk/lib/_internal/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698