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

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

Issue 977613002: Make int and double nullable by default (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: actually upload changes 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (test(element)) return element; 80 if (test(element)) return element;
81 if (length != this.length) { 81 if (length != this.length) {
82 throw new ConcurrentModificationError(this); 82 throw new ConcurrentModificationError(this);
83 } 83 }
84 } 84 }
85 if (orElse != null) return orElse(); 85 if (orElse != null) return orElse();
86 throw IterableElementError.noElement(); 86 throw IterableElementError.noElement();
87 } 87 }
88 E singleWhere(bool test(E element)) { 88 E singleWhere(bool test(E element)) {
89 int length = this.length; 89 int length = this.length;
90 E match = ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", """line 151, col umn 15 of dart:collection/list.dart: """, __x9 is E, false))(null); 90 E match = null;
91 bool matchFound = false; 91 bool matchFound = false;
92 for (int i = 0; i < length; i++) { 92 for (int i = 0; i < length; i++) {
93 E element = this[i]; 93 E element = this[i];
94 if (test(element)) { 94 if (test(element)) {
95 if (matchFound) { 95 if (matchFound) {
96 throw IterableElementError.tooMany(); 96 throw IterableElementError.tooMany();
97 } 97 }
98 matchFound = true; 98 matchFound = true;
99 match = element; 99 match = element;
100 } 100 }
101 if (length != this.length) { 101 if (length != this.length) {
102 throw new ConcurrentModificationError(this); 102 throw new ConcurrentModificationError(this);
103 } 103 }
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, DDC$RT.wrap((dynamic f(E __u10)) { 114 Iterable map(f(E element)) => new MappedListIterable(this, DDC$RT.wrap((dynamic f(E __u5)) {
115 dynamic c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 178, colum n 62 of dart:collection/list.dart: """, x0 is E, false)); 115 dynamic c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 178, colum n 62 of dart:collection/list.dart: """, x0 is E, false));
116 return f == null ? null : c; 116 return f == null ? null : c;
117 } 117 }
118 , f, DDC$RT.type((__t13<E> _) { 118 , f, DDC$RT.type((__t8<E> _) {
119 } 119 }
120 ), __t11, "Wrap", """line 178, column 62 of dart:collection/list.dart: """, f is __t11)); 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); 121 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
122 E reduce(E combine(E previousValue, E element)) { 122 E reduce(E combine(E previousValue, E element)) {
123 int length = this.length; 123 int length = this.length;
124 if (length == 0) throw IterableElementError.noElement(); 124 if (length == 0) throw IterableElementError.noElement();
125 E value = this[0]; 125 E value = this[0];
126 for (int i = 1; i < length; i++) { 126 for (int i = 1; i < length; i++) {
127 value = combine(value, this[i]); 127 value = combine(value, this[i]);
128 if (length != this.length) { 128 if (length != this.length) {
129 throw new ConcurrentModificationError(this); 129 throw new ConcurrentModificationError(this);
130 } 130 }
131 } 131 }
132 return value; 132 return value;
133 } 133 }
134 fold(var initialValue, combine(var previousValue, E element)) { 134 fold(var initialValue, combine(var previousValue, E element)) {
135 var value = initialValue; 135 var value = initialValue;
136 int length = this.length; 136 int length = this.length;
137 for (int i = 0; i < length; i++) { 137 for (int i = 0; i < length; i++) {
138 value = combine(value, this[i]); 138 value = combine(value, this[i]);
139 if (length != this.length) { 139 if (length != this.length) {
140 throw new ConcurrentModificationError(this); 140 throw new ConcurrentModificationError(this);
141 } 141 }
142 } 142 }
143 return value; 143 return value;
144 } 144 }
145 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, ((__x15) => DDC$RT.cast(__x15, Null, int, "CastLiteral", """line 208, column 70 of dart:coll ection/list.dart: """, __x15 is int, true))(null)); 145 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null);
146 Iterable<E> skipWhile(bool test(E element)) { 146 Iterable<E> skipWhile(bool test(E element)) {
147 return new SkipWhileIterable<E>(this, test); 147 return new SkipWhileIterable<E>(this, test);
148 } 148 }
149 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); 149 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count);
150 Iterable<E> takeWhile(bool test(E element)) { 150 Iterable<E> takeWhile(bool test(E element)) {
151 return new TakeWhileIterable<E>(this, test); 151 return new TakeWhileIterable<E>(this, test);
152 } 152 }
153 List<E> toList({ 153 List<E> toList({
154 bool growable : true} 154 bool growable : true}
155 ) { 155 ) {
(...skipping 28 matching lines...) Expand all
184 for (int i = 0; i < this.length; i++) { 184 for (int i = 0; i < this.length; i++) {
185 if (this[i] == element) { 185 if (this[i] == element) {
186 this.setRange(i, this.length - 1, this, i + 1); 186 this.setRange(i, this.length - 1, this, i + 1);
187 this.length -= 1; 187 this.length -= 1;
188 return true; 188 return true;
189 } 189 }
190 } 190 }
191 return false; 191 return false;
192 } 192 }
193 void removeWhere(bool test(E element)) { 193 void removeWhere(bool test(E element)) {
194 _filter(this, DDC$RT.wrap((bool f(E __u16)) { 194 _filter(this, DDC$RT.wrap((bool f(E __u10)) {
195 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 264, column 19 of dart:collection/list.dart: """, x0 is E, false)); 195 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 264, column 19 of dart:collection/list.dart: """, x0 is E, false));
196 return f == null ? null : c; 196 return f == null ? null : c;
197 } 197 }
198 , test, DDC$RT.type((__t19<E> _) { 198 , test, DDC$RT.type((__t13<E> _) {
199 } 199 }
200 ), __t17, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test is __t17), false); 200 ), __t11, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test is __t11), false);
201 } 201 }
202 void retainWhere(bool test(E element)) { 202 void retainWhere(bool test(E element)) {
203 _filter(this, DDC$RT.wrap((bool f(E __u21)) { 203 _filter(this, DDC$RT.wrap((bool f(E __u15)) {
204 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 268, column 19 of dart:collection/list.dart: """, x0 is E, false)); 204 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 268, column 19 of dart:collection/list.dart: """, x0 is E, false));
205 return f == null ? null : c; 205 return f == null ? null : c;
206 } 206 }
207 , test, DDC$RT.type((__t19<E> _) { 207 , test, DDC$RT.type((__t13<E> _) {
208 } 208 }
209 ), __t17, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test is __t17), true); 209 ), __t11, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test is __t11), true);
210 } 210 }
211 static void _filter(List source, bool test(var element), bool retainMatching) { 211 static void _filter(List source, bool test(var element), bool retainMatching) {
212 List retained = []; 212 List retained = [];
213 int length = source.length; 213 int length = source.length;
214 for (int i = 0; i < length; i++) { 214 for (int i = 0; i < length; i++) {
215 var element = source[i]; 215 var element = source[i];
216 if (test(element) == retainMatching) { 216 if (test(element) == retainMatching) {
217 retained.add(element); 217 retained.add(element);
218 } 218 }
219 if (length != source.length) { 219 if (length != source.length) {
(...skipping 14 matching lines...) Expand all
234 } 234 }
235 E result = this[length - 1]; 235 E result = this[length - 1];
236 length--; 236 length--;
237 return result; 237 return result;
238 } 238 }
239 void sort([int compare(E a, E b)]) { 239 void sort([int compare(E a, E b)]) {
240 if (compare == null) { 240 if (compare == null) {
241 var defaultCompare = Comparable.compare; 241 var defaultCompare = Comparable.compare;
242 compare = defaultCompare; 242 compare = defaultCompare;
243 } 243 }
244 Sort.sort(this, DDC$RT.wrap((int f(E __u22, E __u23)) { 244 Sort.sort(this, DDC$RT.wrap((int f(E __u16, E __u17)) {
245 int c(E x0, E x1) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 309, c olumn 21 of dart:collection/list.dart: """, x0 is E, false), DDC$RT.cast(x1, dyn amic, E, "CastParam", """line 309, column 21 of dart:collection/list.dart: """, x1 is E, false)); 245 int c(E x0, E x1) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 309, c olumn 21 of dart:collection/list.dart: """, x0 is E, false), DDC$RT.cast(x1, dyn amic, E, "CastParam", """line 309, column 21 of dart:collection/list.dart: """, x1 is E, false));
246 return f == null ? null : c; 246 return f == null ? null : c;
247 } 247 }
248 , compare, DDC$RT.type((__t27<E> _) { 248 , compare, DDC$RT.type((__t21<E> _) {
249 } 249 }
250 ), __t24, "Wrap", """line 309, column 21 of dart:collection/list.dart: """, comp are is __t24)); 250 ), __t18, "Wrap", """line 309, column 21 of dart:collection/list.dart: """, comp are is __t18));
251 } 251 }
252 void shuffle([Random random]) { 252 void shuffle([Random random]) {
253 if (random == null) random = new Random(); 253 if (random == null) random = new Random();
254 int length = this.length; 254 int length = this.length;
255 while (length > 1) { 255 while (length > 1) {
256 int pos = random.nextInt(length); 256 int pos = random.nextInt(length);
257 length -= 1; 257 length -= 1;
258 var tmp = this[length]; 258 var tmp = this[length];
259 this[length] = this[pos]; 259 this[length] = this[pos];
260 this[pos] = tmp; 260 this[pos] = tmp;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 else { 307 else {
308 otherList = iterable.skip(skipCount).toList(growable: false); 308 otherList = iterable.skip(skipCount).toList(growable: false);
309 otherStart = 0; 309 otherStart = 0;
310 } 310 }
311 if (otherStart + length > otherList.length) { 311 if (otherStart + length > otherList.length) {
312 throw IterableElementError.tooFew(); 312 throw IterableElementError.tooFew();
313 } 313 }
314 if (otherStart < start) { 314 if (otherStart < start) {
315 for (int i = length - 1; i >= 0; i--) { 315 for (int i = length - 1; i >= 0; i--) {
316 this[start + i] = ((__x30) => DDC$RT.cast(__x30, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x30 is E, false))(ot herList[otherStart + i]); 316 this[start + i] = ((__x24) => DDC$RT.cast(__x24, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x24 is E, false))(ot herList[otherStart + i]);
317 } 317 }
318 } 318 }
319 else { 319 else {
320 for (int i = 0; i < length; i++) { 320 for (int i = 0; i < length; i++) {
321 this[start + i] = ((__x31) => DDC$RT.cast(__x31, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x31 is E, false))(ot herList[otherStart + i]); 321 this[start + i] = ((__x25) => DDC$RT.cast(__x25, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x25 is E, false))(ot herList[otherStart + i]);
322 } 322 }
323 } 323 }
324 } 324 }
325 void replaceRange(int start, int end, Iterable<E> newContents) { 325 void replaceRange(int start, int end, Iterable<E> newContents) {
326 RangeError.checkValidRange(start, end, this.length); 326 RangeError.checkValidRange(start, end, this.length);
327 if (newContents is! EfficientLength) { 327 if (newContents is! EfficientLength) {
328 newContents = newContents.toList(); 328 newContents = newContents.toList();
329 } 329 }
330 int removeLength = end - start; 330 int removeLength = end - start;
331 int insertLength = newContents.length; 331 int insertLength = newContents.length;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 413 }
414 else { 414 else {
415 for (E element in iterable) { 415 for (E element in iterable) {
416 this[index++] = element; 416 this[index++] = element;
417 } 417 }
418 } 418 }
419 } 419 }
420 Iterable<E> get reversed => new ReversedListIterable<E>(this); 420 Iterable<E> get reversed => new ReversedListIterable<E>(this);
421 String toString() => IterableBase.iterableToFullString(this, '[', ']'); 421 String toString() => IterableBase.iterableToFullString(this, '[', ']');
422 } 422 }
423 typedef dynamic __t11(dynamic __u12); 423 typedef dynamic __t6(dynamic __u7);
424 typedef dynamic __t13<E>(E __u14); 424 typedef dynamic __t8<E>(E __u9);
425 typedef bool __t17(dynamic __u18); 425 typedef bool __t11(dynamic __u12);
426 typedef bool __t19<E>(E __u20); 426 typedef bool __t13<E>(E __u14);
427 typedef int __t24(dynamic __u25, dynamic __u26); 427 typedef int __t18(dynamic __u19, dynamic __u20);
428 typedef int __t27<E>(E __u28, E __u29); 428 typedef int __t21<E>(E __u22, E __u23);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698