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

Side by Side Diff: test/dart_codegen/expect/_internal/iterable.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._internal; 1 part of dart._internal;
2 abstract class EfficientLength {int get length; 2 abstract class EfficientLength {int get length;
3 } 3 }
4 abstract class ListIterable<E> extends IterableBase<E> implements EfficientLeng th {int get length; 4 abstract class ListIterable<E> extends IterableBase<E> implements EfficientLeng th {int get length;
5 E elementAt(int i); 5 E elementAt(int i);
6 const ListIterable(); 6 const ListIterable();
7 Iterator<E> get iterator => new ListIterator<E>(this); 7 Iterator<E> get iterator => new ListIterator<E>(this);
8 void forEach(void action(E element)) { 8 void forEach(void action(E element)) {
9 int length = this.length; 9 int length = this.length;
10 for (int i = 0; i < length; i++) { 10 for (int i = 0; i < length; i++) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 for (int i = 0; i < length; i++) { 129 for (int i = 0; i < length; i++) {
130 buffer.write(elementAt(i)); 130 buffer.write(elementAt(i));
131 if (length != this.length) { 131 if (length != this.length) {
132 throw new ConcurrentModificationError(this); 132 throw new ConcurrentModificationError(this);
133 } 133 }
134 } 134 }
135 return buffer.toString(); 135 return buffer.toString();
136 } 136 }
137 } 137 }
138 Iterable<E> where(bool test(E element)) => super.where(test); 138 Iterable<E> where(bool test(E element)) => super.where(test);
139 Iterable map(f(E element)) => new MappedListIterable(this, DEVC$RT.wrap((dynami c f(E __u0)) { 139 Iterable map(f(E element)) => new MappedListIterable(this, f);
140 dynamic c(E x0) => f(DEVC$RT.cast(x0, dynamic, E, "CastParam", """line 175, colu mn 62 of dart:_internal/iterable.dart: """, x0 is E, false));
141 return f == null ? null : c;
142 }
143 , f, null, __t1, "Wrap", """line 175, column 62 of dart:_internal/iterable.dart: """, f is __t1));
144 E reduce(E combine(var value, E element)) { 140 E reduce(E combine(var value, E element)) {
145 int length = this.length; 141 int length = this.length;
146 if (length == 0) throw IterableElementError.noElement(); 142 if (length == 0) throw IterableElementError.noElement();
147 E value = elementAt(0); 143 E value = elementAt(0);
148 for (int i = 1; i < length; i++) { 144 for (int i = 1; i < length; i++) {
149 value = combine(value, elementAt(i)); 145 value = combine(value, elementAt(i));
150 if (length != this.length) { 146 if (length != this.length) {
151 throw new ConcurrentModificationError(this); 147 throw new ConcurrentModificationError(this);
152 } 148 }
153 } 149 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 class MappedListIterable<S, T> extends ListIterable<T> implements EfficientLeng th {final Iterable<S> _source; 328 class MappedListIterable<S, T> extends ListIterable<T> implements EfficientLeng th {final Iterable<S> _source;
333 final _Transformation<S, T> _f; 329 final _Transformation<S, T> _f;
334 MappedListIterable(this._source, T this._f(S value)); 330 MappedListIterable(this._source, T this._f(S value));
335 int get length => _source.length; 331 int get length => _source.length;
336 T elementAt(int index) => _f(_source.elementAt(index)); 332 T elementAt(int index) => _f(_source.elementAt(index));
337 } 333 }
338 typedef bool _ElementPredicate<E>(E element); 334 typedef bool _ElementPredicate<E>(E element);
339 class WhereIterable<E> extends IterableBase<E> {final Iterable<E> _iterable; 335 class WhereIterable<E> extends IterableBase<E> {final Iterable<E> _iterable;
340 final _ElementPredicate _f; 336 final _ElementPredicate _f;
341 WhereIterable(this._iterable, bool this._f(E element)); 337 WhereIterable(this._iterable, bool this._f(E element));
342 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f); 338 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, DEVC$RT.wr ap((bool f(dynamic __u0)) {
339 bool c(dynamic x0) => f(x0);
340 return f == null ? null : c;
341 }
342 , _f, null, DEVC$RT.type((__t1<E> _) {
343 }
344 ), "Wrap", """line 425, column 72 of dart:_internal/iterable.dart: """, _f is __ t1<E>));
343 } 345 }
344 class WhereIterator<E> extends Iterator<E> {final Iterator<E> _iterator; 346 class WhereIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
345 final _ElementPredicate _f; 347 final _ElementPredicate _f;
346 WhereIterator(this._iterator, bool this._f(E element)); 348 WhereIterator(this._iterator, bool this._f(E element));
347 bool moveNext() { 349 bool moveNext() {
348 while (_iterator.moveNext()) { 350 while (_iterator.moveNext()) {
349 if (_f(_iterator.current)) { 351 if (_f(_iterator.current)) {
350 return true; 352 return true;
351 } 353 }
352 } 354 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 439 }
438 E get current { 440 E get current {
439 if (_remaining < 0) return null; 441 if (_remaining < 0) return null;
440 return _iterator.current; 442 return _iterator.current;
441 } 443 }
442 } 444 }
443 class TakeWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ; 445 class TakeWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ;
444 final _ElementPredicate _f; 446 final _ElementPredicate _f;
445 TakeWhileIterable(this._iterable, bool this._f(E element)); 447 TakeWhileIterable(this._iterable, bool this._f(E element));
446 Iterator<E> get iterator { 448 Iterator<E> get iterator {
447 return new TakeWhileIterator<E>(_iterable.iterator, _f); 449 return new TakeWhileIterator<E>(_iterable.iterator, DEVC$RT.wrap((bool f(dynamic __u13)) {
450 bool c(dynamic x0) => f(x0);
451 return f == null ? null : c;
452 }
453 , _f, null, DEVC$RT.type((__t14<E> _) {
454 }
455 ), "Wrap", """line 555, column 57 of dart:_internal/iterable.dart: """, _f is __ t14<E>));
448 } 456 }
449 } 457 }
450 class TakeWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator; 458 class TakeWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
451 final _ElementPredicate _f; 459 final _ElementPredicate _f;
452 bool _isFinished = false; 460 bool _isFinished = false;
453 TakeWhileIterator(this._iterator, bool this._f(E element)); 461 TakeWhileIterator(this._iterator, bool this._f(E element));
454 bool moveNext() { 462 bool moveNext() {
455 if (_isFinished) return false; 463 if (_isFinished) return false;
456 if (!_iterator.moveNext() || !_f(_iterator.current)) { 464 if (!_iterator.moveNext() || !_f(_iterator.current)) {
457 _isFinished = true; 465 _isFinished = true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 for (int i = 0; i < _skipCount; i++) _iterator.moveNext(); 512 for (int i = 0; i < _skipCount; i++) _iterator.moveNext();
505 _skipCount = 0; 513 _skipCount = 0;
506 return _iterator.moveNext(); 514 return _iterator.moveNext();
507 } 515 }
508 E get current => _iterator.current; 516 E get current => _iterator.current;
509 } 517 }
510 class SkipWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ; 518 class SkipWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ;
511 final _ElementPredicate _f; 519 final _ElementPredicate _f;
512 SkipWhileIterable(this._iterable, bool this._f(E element)); 520 SkipWhileIterable(this._iterable, bool this._f(E element));
513 Iterator<E> get iterator { 521 Iterator<E> get iterator {
514 return new SkipWhileIterator<E>(_iterable.iterator, _f); 522 return new SkipWhileIterator<E>(_iterable.iterator, DEVC$RT.wrap((bool f(dynamic __u16)) {
523 bool c(dynamic x0) => f(x0);
524 return f == null ? null : c;
525 }
526 , _f, null, DEVC$RT.type((__t17<E> _) {
527 }
528 ), "Wrap", """line 648, column 57 of dart:_internal/iterable.dart: """, _f is __ t17<E>));
515 } 529 }
516 } 530 }
517 class SkipWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator; 531 class SkipWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
518 final _ElementPredicate _f; 532 final _ElementPredicate _f;
519 bool _hasSkipped = false; 533 bool _hasSkipped = false;
520 SkipWhileIterator(this._iterator, bool this._f(E element)); 534 SkipWhileIterator(this._iterator, bool this._f(E element));
521 bool moveNext() { 535 bool moveNext() {
522 if (!_hasSkipped) { 536 if (!_hasSkipped) {
523 _hasSkipped = true; 537 _hasSkipped = true;
524 while (_iterator.moveNext()) { 538 while (_iterator.moveNext()) {
525 if (!_f(_iterator.current)) return true; 539 if (!_f(_iterator.current)) return true;
526 } 540 }
527 } 541 }
528 return _iterator.moveNext(); 542 return _iterator.moveNext();
529 } 543 }
530 E get current => _iterator.current; 544 E get current => _iterator.current;
531 } 545 }
532 class EmptyIterable<E> extends IterableBase<E> implements EfficientLength {cons t EmptyIterable(); 546 class EmptyIterable<E> extends IterableBase<E> implements EfficientLength {cons t EmptyIterable();
533 Iterator<E> get iterator => ((__x13) => DEVC$RT.cast(__x13, null, DEVC$RT.type( (Iterator<E> _) { 547 Iterator<E> get iterator => ((__x19) => DEVC$RT.cast(__x19, null, DEVC$RT.type( (Iterator<E> _) {
534 } 548 }
535 ), "CastExact", """line 678, column 31 of dart:_internal/iterable.dart: """, __x 13 is Iterator<E>, false))(const EmptyIterator()); 549 ), "CastExact", """line 678, column 31 of dart:_internal/iterable.dart: """, __x 19 is Iterator<E>, false))(const EmptyIterator());
536 void forEach(void action(E element)) { 550 void forEach(void action(E element)) {
537 } 551 }
538 bool get isEmpty => true; 552 bool get isEmpty => true;
539 int get length => 0; 553 int get length => 0;
540 E get first { 554 E get first {
541 throw IterableElementError.noElement(); 555 throw IterableElementError.noElement();
542 } 556 }
543 E get last { 557 E get last {
544 throw IterableElementError.noElement(); 558 throw IterableElementError.noElement();
545 } 559 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 buffer.write(list[i]); 771 buffer.write(list[i]);
758 } 772 }
759 } 773 }
760 return buffer.toString(); 774 return buffer.toString();
761 } 775 }
762 Iterable<T> where(Iterable iterable, bool f(var element)) { 776 Iterable<T> where(Iterable iterable, bool f(var element)) {
763 return new WhereIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dynami c> _) { 777 return new WhereIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dynami c> _) {
764 } 778 }
765 ), DEVC$RT.type((Iterable<T> _) { 779 ), DEVC$RT.type((Iterable<T> _) {
766 } 780 }
767 ), "CastDynamic", """line 961, column 33 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), f); 781 ), "CastDynamic", """line 961, column 33 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), DEVC$RT.wrap((bool f(dynamic __u20)) {
782 bool c(dynamic x0) => f(x0);
783 return f == null ? null : c;
784 }
785 , f, null, DEVC$RT.type((__t21<T> _) {
786 }
787 ), "Wrap", """line 961, column 43 of dart:_internal/iterable.dart: """, f is __t 21<T>));
768 } 788 }
769 static Iterable map(Iterable iterable, f(var element)) { 789 static Iterable map(Iterable iterable, f(var element)) {
770 return new MappedIterable(iterable, f); 790 return new MappedIterable(iterable, f);
771 } 791 }
772 static Iterable mapList(List list, f(var element)) { 792 static Iterable mapList(List list, f(var element)) {
773 return new MappedListIterable(list, f); 793 return new MappedListIterable(list, f);
774 } 794 }
775 static Iterable expand(Iterable iterable, Iterable f(var element)) { 795 static Iterable expand(Iterable iterable, Iterable f(var element)) {
776 return new ExpandIterable(iterable, f); 796 return new ExpandIterable(iterable, f);
777 } 797 }
778 Iterable<T> takeList(List list, int n) { 798 Iterable<T> takeList(List list, int n) {
779 return new SubListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _) { 799 return new SubListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _) {
780 } 800 }
781 ), DEVC$RT.type((Iterable<T> _) { 801 ), DEVC$RT.type((Iterable<T> _) {
782 } 802 }
783 ), "CastDynamic", """line 978, column 35 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false), 0, n); 803 ), "CastDynamic", """line 978, column 35 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false), 0, n);
784 } 804 }
785 Iterable<T> takeWhile(Iterable iterable, bool test(var value)) { 805 Iterable<T> takeWhile(Iterable iterable, bool test(var value)) {
786 return new TakeWhileIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dy namic> _) { 806 return new TakeWhileIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dy namic> _) {
787 } 807 }
788 ), DEVC$RT.type((Iterable<T> _) { 808 ), DEVC$RT.type((Iterable<T> _) {
789 } 809 }
790 ), "CastDynamic", """line 983, column 37 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), test); 810 ), "CastDynamic", """line 983, column 37 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), DEVC$RT.wrap((bool f(dynamic __u23)) {
811 bool c(dynamic x0) => f(x0);
812 return f == null ? null : c;
813 }
814 , test, null, DEVC$RT.type((__t21<T> _) {
815 }
816 ), "Wrap", """line 983, column 47 of dart:_internal/iterable.dart: """, test is __t21<T>));
791 } 817 }
792 Iterable<T> skipList(List list, int n) { 818 Iterable<T> skipList(List list, int n) {
793 return new SubListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _) { 819 return new SubListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _) {
794 } 820 }
795 ), DEVC$RT.type((Iterable<T> _) { 821 ), DEVC$RT.type((Iterable<T> _) {
796 } 822 }
797 ), "CastDynamic", """line 988, column 35 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false), n, null); 823 ), "CastDynamic", """line 988, column 35 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false), n, null);
798 } 824 }
799 Iterable<T> skipWhile(Iterable iterable, bool test(var value)) { 825 Iterable<T> skipWhile(Iterable iterable, bool test(var value)) {
800 return new SkipWhileIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dy namic> _) { 826 return new SkipWhileIterable<T>(DEVC$RT.cast(iterable, DEVC$RT.type((Iterable<dy namic> _) {
801 } 827 }
802 ), DEVC$RT.type((Iterable<T> _) { 828 ), DEVC$RT.type((Iterable<T> _) {
803 } 829 }
804 ), "CastDynamic", """line 993, column 37 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), test); 830 ), "CastDynamic", """line 993, column 37 of dart:_internal/iterable.dart: """, i terable is Iterable<T>, false), DEVC$RT.wrap((bool f(dynamic __u24)) {
831 bool c(dynamic x0) => f(x0);
832 return f == null ? null : c;
833 }
834 , test, null, DEVC$RT.type((__t21<T> _) {
835 }
836 ), "Wrap", """line 993, column 47 of dart:_internal/iterable.dart: """, test is __t21<T>));
805 } 837 }
806 Iterable<T> reversedList(List list) { 838 Iterable<T> reversedList(List list) {
807 return new ReversedListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic > _) { 839 return new ReversedListIterable<T>(DEVC$RT.cast(list, DEVC$RT.type((List<dynamic > _) {
808 } 840 }
809 ), DEVC$RT.type((Iterable<T> _) { 841 ), DEVC$RT.type((Iterable<T> _) {
810 } 842 }
811 ), "CastDynamic", """line 997, column 40 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false)); 843 ), "CastDynamic", """line 997, column 40 of dart:_internal/iterable.dart: """, l ist is Iterable<T>, false));
812 } 844 }
813 static void sortList(List list, int compare(a, b)) { 845 static void sortList(List list, int compare(a, b)) {
814 if (compare == null) compare = DEVC$RT.wrap((int f(Comparable<dynamic> __u14, Co mparable<dynamic> __u15)) { 846 if (compare == null) compare = Comparable.compare;
815 int c(Comparable<dynamic> x0, Comparable<dynamic> x1) => f(DEVC$RT.cast(x0, dyna mic, DEVC$RT.type((Comparable<dynamic> _) {
816 }
817 ), "CastParam", """line 1001, column 36 of dart:_internal/iterable.dart: """, x0 is Comparable<dynamic>, true), DEVC$RT.cast(x1, dynamic, DEVC$RT.type((Comparab le<dynamic> _) {
818 }
819 ), "CastParam", """line 1001, column 36 of dart:_internal/iterable.dart: """, x1 is Comparable<dynamic>, true));
820 return f == null ? null : c;
821 }
822 , Comparable.compare, __t19, __t16, "Wrap", """line 1001, column 36 of dart:_int ernal/iterable.dart: """, Comparable.compare is __t16);
823 Sort.sort(list, compare); 847 Sort.sort(list, compare);
824 } 848 }
825 static void shuffleList(List list, Random random) { 849 static void shuffleList(List list, Random random) {
826 if (random == null) random = new Random(); 850 if (random == null) random = new Random();
827 int length = list.length; 851 int length = list.length;
828 while (length > 1) { 852 while (length > 1) {
829 int pos = random.nextInt(length); 853 int pos = random.nextInt(length);
830 length -= 1; 854 length -= 1;
831 var tmp = list[length]; 855 var tmp = list[length];
832 list[length] = list[pos]; 856 list[length] = list[pos];
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 result.add(element); 986 result.add(element);
963 } 987 }
964 } 988 }
965 return result; 989 return result;
966 } 990 }
967 } 991 }
968 abstract class IterableElementError {static StateError noElement() => new State Error("No element"); 992 abstract class IterableElementError {static StateError noElement() => new State Error("No element");
969 static StateError tooMany() => new StateError("Too many elements"); 993 static StateError tooMany() => new StateError("Too many elements");
970 static StateError tooFew() => new StateError("Too few elements"); 994 static StateError tooFew() => new StateError("Too few elements");
971 } 995 }
972 typedef dynamic __t1(dynamic __u2); 996 typedef bool __t1<E>(E __u2);
973 typedef dynamic __t3<E>(E __u4); 997 typedef bool __t3(dynamic __u4);
974 typedef Iterable<T> __t7<S, T>(S __u8); 998 typedef Iterable<T> __t7<S, T>(S __u8);
975 typedef Iterable<dynamic> __t9(dynamic __u10); 999 typedef Iterable<dynamic> __t9(dynamic __u10);
976 typedef int __t16(dynamic __u17, dynamic __u18); 1000 typedef bool __t14<E>(E __u15);
977 typedef int __t19(Comparable<dynamic> __u20, Comparable<dynamic> __u21); 1001 typedef bool __t17<E>(E __u18);
1002 typedef bool __t21<T>(T __u22);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698