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

Side by Side Diff: test/dart_codegen/expect/collection/list.dart

Issue 1010893004: Allow S->T <: dynamic->T (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Add comment 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 unified diff | Download patch
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 abstract class ListBase<E> extends Object with ListMixin<E> {static String list ToString(List list) => IterableBase.iterableToFullString(list, '[', ']'); 2 abstract class ListBase<E> extends Object with ListMixin<E> {static String list ToString(List list) => IterableBase.iterableToFullString(list, '[', ']');
3 } 3 }
4 abstract class ListMixin<E> implements List<E> {Iterator<E> get iterator => new ListIterator<E>(this); 4 abstract class ListMixin<E> implements List<E> {Iterator<E> get iterator => new ListIterator<E>(this);
5 E elementAt(int index) => this[index]; 5 E elementAt(int index) => this[index];
6 void forEach(void action(E element)) { 6 void forEach(void action(E element)) {
7 int length = this.length; 7 int length = this.length;
8 for (int i = 0; i < length; i++) { 8 for (int i = 0; i < length; i++) {
9 action(this[i]); 9 action(this[i]);
10 if (length != this.length) { 10 if (length != this.length) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 if (matchFound) return match; 105 if (matchFound) return match;
106 throw IterableElementError.noElement(); 106 throw IterableElementError.noElement();
107 } 107 }
108 String join([String separator = ""]) { 108 String join([String separator = ""]) {
109 if (length == 0) return ""; 109 if (length == 0) return "";
110 StringBuffer buffer = new StringBuffer()..writeAll(this, separator); 110 StringBuffer buffer = new StringBuffer()..writeAll(this, separator);
111 return buffer.toString(); 111 return buffer.toString();
112 } 112 }
113 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); 113 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
114 Iterable map(f(E element)) => new MappedListIterable(this, DEVC$RT.wrap((dynami c f(E __u5)) { 114 Iterable map(f(E element)) => new MappedListIterable(this, f);
115 dynamic c(E x0) => f(DEVC$RT.cast(x0, dynamic, E, "CastParam", """line 178, colu mn 62 of dart:collection/list.dart: """, x0 is E, false));
116 return f == null ? null : c;
117 }
118 , f, DEVC$RT.type((__t8<E> _) {
119 }
120 ), __t6, "Wrap", """line 178, column 62 of dart:collection/list.dart: """, f is __t6));
121 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f); 115 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
122 E reduce(E combine(E previousValue, E element)) { 116 E reduce(E combine(E previousValue, E element)) {
123 int length = this.length; 117 int length = this.length;
124 if (length == 0) throw IterableElementError.noElement(); 118 if (length == 0) throw IterableElementError.noElement();
125 E value = this[0]; 119 E value = this[0];
126 for (int i = 1; i < length; i++) { 120 for (int i = 1; i < length; i++) {
127 value = combine(value, this[i]); 121 value = combine(value, this[i]);
128 if (length != this.length) { 122 if (length != this.length) {
129 throw new ConcurrentModificationError(this); 123 throw new ConcurrentModificationError(this);
130 } 124 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 for (int i = 0; i < this.length; i++) { 178 for (int i = 0; i < this.length; i++) {
185 if (this[i] == element) { 179 if (this[i] == element) {
186 this.setRange(i, this.length - 1, this, i + 1); 180 this.setRange(i, this.length - 1, this, i + 1);
187 this.length -= 1; 181 this.length -= 1;
188 return true; 182 return true;
189 } 183 }
190 } 184 }
191 return false; 185 return false;
192 } 186 }
193 void removeWhere(bool test(E element)) { 187 void removeWhere(bool test(E element)) {
194 _filter(this, DEVC$RT.wrap((bool f(E __u10)) { 188 _filter(this, test, false);
195 bool c(E x0) => f(DEVC$RT.cast(x0, dynamic, E, "CastParam", """line 264, colum n 19 of dart:collection/list.dart: """, x0 is E, false));
196 return f == null ? null : c;
197 }
198 , test, DEVC$RT.type((__t13<E> _) {
199 }
200 ), __t11, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test is __t11), false);
201 } 189 }
202 void retainWhere(bool test(E element)) { 190 void retainWhere(bool test(E element)) {
203 _filter(this, DEVC$RT.wrap((bool f(E __u15)) { 191 _filter(this, test, true);
204 bool c(E x0) => f(DEVC$RT.cast(x0, dynamic, E, "CastParam", """line 268, colum n 19 of dart:collection/list.dart: """, x0 is E, false));
205 return f == null ? null : c;
206 }
207 , test, DEVC$RT.type((__t13<E> _) {
208 }
209 ), __t11, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test is __t11), true);
210 } 192 }
211 static void _filter(List source, bool test(var element), bool retainMatching) { 193 static void _filter(List source, bool test(var element), bool retainMatching) {
212 List retained = []; 194 List retained = [];
213 int length = source.length; 195 int length = source.length;
214 for (int i = 0; i < length; i++) { 196 for (int i = 0; i < length; i++) {
215 var element = source[i]; 197 var element = source[i];
216 if (test(element) == retainMatching) { 198 if (test(element) == retainMatching) {
217 retained.add(element); 199 retained.add(element);
218 } 200 }
219 if (length != source.length) { 201 if (length != source.length) {
(...skipping 14 matching lines...) Expand all
234 } 216 }
235 E result = this[length - 1]; 217 E result = this[length - 1];
236 length--; 218 length--;
237 return result; 219 return result;
238 } 220 }
239 void sort([int compare(E a, E b)]) { 221 void sort([int compare(E a, E b)]) {
240 if (compare == null) { 222 if (compare == null) {
241 var defaultCompare = Comparable.compare; 223 var defaultCompare = Comparable.compare;
242 compare = defaultCompare; 224 compare = defaultCompare;
243 } 225 }
244 Sort.sort(this, DEVC$RT.wrap((int f(E __u16, E __u17)) { 226 Sort.sort(this, compare);
245 int c(E x0, E x1) => f(DEVC$RT.cast(x0, dynamic, E, "CastParam", """line 309, column 21 of dart:collection/list.dart: """, x0 is E, false), DEVC$RT.cast(x1, d ynamic, E, "CastParam", """line 309, column 21 of dart:collection/list.dart: """ , x1 is E, false));
246 return f == null ? null : c;
247 }
248 , compare, DEVC$RT.type((__t21<E> _) {
249 }
250 ), __t18, "Wrap", """line 309, column 21 of dart:collection/list.dart: """, comp are is __t18));
251 } 227 }
252 void shuffle([Random random]) { 228 void shuffle([Random random]) {
253 if (random == null) random = new Random(); 229 if (random == null) random = new Random();
254 int length = this.length; 230 int length = this.length;
255 while (length > 1) { 231 while (length > 1) {
256 int pos = random.nextInt(length); 232 int pos = random.nextInt(length);
257 length -= 1; 233 length -= 1;
258 var tmp = this[length]; 234 var tmp = this[length];
259 this[length] = this[pos]; 235 this[length] = this[pos];
260 this[pos] = tmp; 236 this[pos] = tmp;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 282 }
307 else { 283 else {
308 otherList = iterable.skip(skipCount).toList(growable: false); 284 otherList = iterable.skip(skipCount).toList(growable: false);
309 otherStart = 0; 285 otherStart = 0;
310 } 286 }
311 if (otherStart + length > otherList.length) { 287 if (otherStart + length > otherList.length) {
312 throw IterableElementError.tooFew(); 288 throw IterableElementError.tooFew();
313 } 289 }
314 if (otherStart < start) { 290 if (otherStart < start) {
315 for (int i = length - 1; i >= 0; i--) { 291 for (int i = length - 1; i >= 0; i--) {
316 this[start + i] = ((__x24) => DEVC$RT.cast(__x24, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x24 is E, false))(o therList[otherStart + i]); 292 this[start + i] = ((__x11) => DEVC$RT.cast(__x11, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x11 is E, false))(o therList[otherStart + i]);
317 } 293 }
318 } 294 }
319 else { 295 else {
320 for (int i = 0; i < length; i++) { 296 for (int i = 0; i < length; i++) {
321 this[start + i] = ((__x25) => DEVC$RT.cast(__x25, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x25 is E, false))(o therList[otherStart + i]); 297 this[start + i] = ((__x12) => DEVC$RT.cast(__x12, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x12 is E, false))(o therList[otherStart + i]);
322 } 298 }
323 } 299 }
324 } 300 }
325 void replaceRange(int start, int end, Iterable<E> newContents) { 301 void replaceRange(int start, int end, Iterable<E> newContents) {
326 RangeError.checkValidRange(start, end, this.length); 302 RangeError.checkValidRange(start, end, this.length);
327 if (newContents is! EfficientLength) { 303 if (newContents is! EfficientLength) {
328 newContents = newContents.toList(); 304 newContents = newContents.toList();
329 } 305 }
330 int removeLength = end - start; 306 int removeLength = end - start;
331 int insertLength = newContents.length; 307 int insertLength = newContents.length;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 389 }
414 else { 390 else {
415 for (E element in iterable) { 391 for (E element in iterable) {
416 this[index++] = element; 392 this[index++] = element;
417 } 393 }
418 } 394 }
419 } 395 }
420 Iterable<E> get reversed => new ReversedListIterable<E>(this); 396 Iterable<E> get reversed => new ReversedListIterable<E>(this);
421 String toString() => IterableBase.iterableToFullString(this, '[', ']'); 397 String toString() => IterableBase.iterableToFullString(this, '[', ']');
422 } 398 }
423 typedef dynamic __t6(dynamic __u7);
424 typedef dynamic __t8<E>(E __u9);
425 typedef bool __t11(dynamic __u12);
426 typedef bool __t13<E>(E __u14);
427 typedef int __t18(dynamic __u19, dynamic __u20);
428 typedef int __t21<E>(E __u22, E __u23);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698