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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/js_array.dart

Issue 2311513002: Fix type errors in sort(). (Closed)
Patch Set: Use Comparable.compare(). Created 4 years, 3 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart._interceptors; 5 part of dart._interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [List]. The compiler recognizes this 8 * The interceptor class for [List]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (!test(element)) return false; 456 if (!test(element)) return false;
457 if (this.length != end) throw new ConcurrentModificationError(this); 457 if (this.length != end) throw new ConcurrentModificationError(this);
458 } 458 }
459 return true; 459 return true;
460 } 460 }
461 461
462 Iterable<E> get reversed => new ReversedListIterable<E>(this); 462 Iterable<E> get reversed => new ReversedListIterable<E>(this);
463 463
464 void sort([int compare(E a, E b)]) { 464 void sort([int compare(E a, E b)]) {
465 checkMutable('sort'); 465 checkMutable('sort');
466 Sort.sort(this, compare == null ? Comparable.compare : compare); 466 if (compare == null) {
467 Sort.sort(this, (a, b) => Comparable.compare(a, b));
468 } else {
469 Sort.sort(this, compare);
470 }
467 } 471 }
468 472
469 void shuffle([Random random]) { 473 void shuffle([Random random]) {
470 checkMutable('shuffle'); 474 checkMutable('shuffle');
471 if (random == null) random = new Random(); 475 if (random == null) random = new Random();
472 int length = this.length; 476 int length = this.length;
473 while (length > 1) { 477 while (length > 1) {
474 int pos = random.nextInt(length); 478 int pos = random.nextInt(length);
475 length -= 1; 479 length -= 1;
476 var tmp = this[length]; 480 var tmp = this[length];
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 618
615 if (_index >= length) { 619 if (_index >= length) {
616 _current = null; 620 _current = null;
617 return false; 621 return false;
618 } 622 }
619 _current = _iterable[_index]; 623 _current = _iterable[_index];
620 _index++; 624 _index++;
621 return true; 625 return true;
622 } 626 }
623 } 627 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/lib/collection/list.dart ('k') | pkg/dev_compiler/tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698