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

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

Issue 1122313002: Typing fixes to eliminate casts/dcalls (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 abstract class IterableMixin<E> implements Iterable<E> {Iterable map(f(E elemen t)) => new MappedIterable<E, dynamic>(this, f); 2 abstract class IterableMixin<E> implements Iterable<E> {Iterable map(f(E elemen t)) => new MappedIterable<E, dynamic>(this, f);
3 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); 3 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
4 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f); 4 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
5 bool contains(Object element) { 5 bool contains(Object element) {
6 for (E e in this) { 6 for (E e in this) {
7 if (e == element) return true; 7 if (e == element) return true;
8 } 8 }
9 return false; 9 return false;
10 } 10 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Iterable<E> takeWhile(bool test(E value)) { 77 Iterable<E> takeWhile(bool test(E value)) {
78 return new TakeWhileIterable<E>(this, test); 78 return new TakeWhileIterable<E>(this, test);
79 } 79 }
80 Iterable<E> skip(int n) { 80 Iterable<E> skip(int n) {
81 return new SkipIterable<E>(this, n); 81 return new SkipIterable<E>(this, n);
82 } 82 }
83 Iterable<E> skipWhile(bool test(E value)) { 83 Iterable<E> skipWhile(bool test(E value)) {
84 return new SkipWhileIterable<E>(this, test); 84 return new SkipWhileIterable<E>(this, test);
85 } 85 }
86 E get first { 86 E get first {
87 Iterator it = iterator; 87 Iterator<E> it = iterator;
88 if (!it.moveNext()) { 88 if (!it.moveNext()) {
89 throw IterableElementError.noElement(); 89 throw IterableElementError.noElement();
90 } 90 }
91 return DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 127, col umn 12 of dart:collection/iterable.dart: """, it.current is E, false); 91 return it.current;
92 } 92 }
93 E get last { 93 E get last {
94 Iterator it = iterator; 94 Iterator<E> it = iterator;
95 if (!it.moveNext()) { 95 if (!it.moveNext()) {
96 throw IterableElementError.noElement(); 96 throw IterableElementError.noElement();
97 } 97 }
98 E result; 98 E result;
99 do { 99 do {
100 result = DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 137, column 16 of dart:collection/iterable.dart: """, it.current is E, false); 100 result = it.current;
101 } 101 }
102 while (it.moveNext()); return result; 102 while (it.moveNext()); return result;
103 } 103 }
104 E get single { 104 E get single {
105 Iterator it = iterator; 105 Iterator<E> it = iterator;
106 if (!it.moveNext()) throw IterableElementError.noElement(); 106 if (!it.moveNext()) throw IterableElementError.noElement();
107 E result = DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 145, column 16 of dart:collection/iterable.dart: """, it.current is E, false); 107 E result = it.current;
108 if (it.moveNext()) throw IterableElementError.tooMany(); 108 if (it.moveNext()) throw IterableElementError.tooMany();
109 return result; 109 return result;
110 } 110 }
111 E firstWhere(bool test(E value), { 111 E firstWhere(bool test(E value), {
112 E orElse()} 112 E orElse()}
113 ) { 113 ) {
114 for (E element in this) { 114 for (E element in this) {
115 if (test(element)) return element; 115 if (test(element)) return element;
116 } 116 }
117 if (orElse != null) return orElse(); 117 if (orElse != null) return orElse();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (f(element)) return true; 217 if (f(element)) return true;
218 } 218 }
219 return false; 219 return false;
220 } 220 }
221 List<E> toList({ 221 List<E> toList({
222 bool growable : true} 222 bool growable : true}
223 ) => new List<E>.from(this, growable: growable); 223 ) => new List<E>.from(this, growable: growable);
224 Set<E> toSet() => new Set<E>.from(this); 224 Set<E> toSet() => new Set<E>.from(this);
225 int get length { 225 int get length {
226 assert (this is! EfficientLength); int count = 0; 226 assert (this is! EfficientLength); int count = 0;
227 Iterator it = iterator; 227 Iterator<E> it = iterator;
228 while (it.moveNext()) { 228 while (it.moveNext()) {
229 count++; 229 count++;
230 } 230 }
231 return count; 231 return count;
232 } 232 }
233 bool get isEmpty => !iterator.moveNext(); 233 bool get isEmpty => !iterator.moveNext();
234 bool get isNotEmpty => !isEmpty; 234 bool get isNotEmpty => !isEmpty;
235 Iterable<E> take(int n) { 235 Iterable<E> take(int n) {
236 return new TakeIterable<E>(this, n); 236 return new TakeIterable<E>(this, n);
237 } 237 }
238 Iterable<E> takeWhile(bool test(E value)) { 238 Iterable<E> takeWhile(bool test(E value)) {
239 return new TakeWhileIterable<E>(this, test); 239 return new TakeWhileIterable<E>(this, test);
240 } 240 }
241 Iterable<E> skip(int n) { 241 Iterable<E> skip(int n) {
242 return new SkipIterable<E>(this, n); 242 return new SkipIterable<E>(this, n);
243 } 243 }
244 Iterable<E> skipWhile(bool test(E value)) { 244 Iterable<E> skipWhile(bool test(E value)) {
245 return new SkipWhileIterable<E>(this, test); 245 return new SkipWhileIterable<E>(this, test);
246 } 246 }
247 E get first { 247 E get first {
248 Iterator it = iterator; 248 Iterator<E> it = iterator;
249 if (!it.moveNext()) { 249 if (!it.moveNext()) {
250 throw IterableElementError.noElement(); 250 throw IterableElementError.noElement();
251 } 251 }
252 return DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 323, colum n 12 of dart:collection/iterable.dart: """, it.current is E, false); 252 return it.current;
253 } 253 }
254 E get last { 254 E get last {
255 Iterator it = iterator; 255 Iterator<E> it = iterator;
256 if (!it.moveNext()) { 256 if (!it.moveNext()) {
257 throw IterableElementError.noElement(); 257 throw IterableElementError.noElement();
258 } 258 }
259 E result; 259 E result;
260 do { 260 do {
261 result = DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 333, co lumn 16 of dart:collection/iterable.dart: """, it.current is E, false); 261 result = it.current;
262 } 262 }
263 while (it.moveNext()); return result; 263 while (it.moveNext()); return result;
264 } 264 }
265 E get single { 265 E get single {
266 Iterator it = iterator; 266 Iterator<E> it = iterator;
267 if (!it.moveNext()) throw IterableElementError.noElement(); 267 if (!it.moveNext()) throw IterableElementError.noElement();
268 E result = DEVC$RT.cast(it.current, dynamic, E, "CompositeCast", """line 341, c olumn 16 of dart:collection/iterable.dart: """, it.current is E, false); 268 E result = it.current;
269 if (it.moveNext()) throw IterableElementError.tooMany(); 269 if (it.moveNext()) throw IterableElementError.tooMany();
270 return result; 270 return result;
271 } 271 }
272 E firstWhere(bool test(E value), { 272 E firstWhere(bool test(E value), {
273 E orElse()} 273 E orElse()}
274 ) { 274 ) {
275 for (E element in this) { 275 for (E element in this) {
276 if (test(element)) return element; 276 if (test(element)) return element;
277 } 277 }
278 if (orElse != null) return orElse(); 278 if (orElse != null) return orElse();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 length += ELLIPSIS_SIZE + OVERHEAD; 425 length += ELLIPSIS_SIZE + OVERHEAD;
426 } 426 }
427 } 427 }
428 if (elision != null) { 428 if (elision != null) {
429 parts.add(elision); 429 parts.add(elision);
430 } 430 }
431 parts.add(penultimateString); 431 parts.add(penultimateString);
432 parts.add(ultimateString); 432 parts.add(ultimateString);
433 } 433 }
434 } 434 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/collection/hash_map.dart ('k') | test/dart_codegen/expect/collection/set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698