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

Side by Side Diff: lib/runtime/dart/_internal.js

Issue 1117793002: add checks needed for covariant generics, and List<E> (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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
« no previous file with comments | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/runtime/dart/collection.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var _internal; 1 var _internal;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class EfficientLength extends core.Object {} 4 class EfficientLength extends core.Object {}
5 let ListIterable$ = dart.generic(function(E) { 5 let ListIterable$ = dart.generic(function(E) {
6 class ListIterable extends collection.IterableBase$(E) { 6 class ListIterable extends collection.IterableBase$(E) {
7 ListIterable() { 7 ListIterable() {
8 super.IterableBase(); 8 super.IterableBase();
9 } 9 }
10 get [core.$iterator]() { 10 get [core.$iterator]() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 66 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
67 if (test(this[core.$elementAt](i))) 67 if (test(this[core.$elementAt](i)))
68 return true; 68 return true;
69 if (length != this[core.$length]) { 69 if (length != this[core.$length]) {
70 throw new core.ConcurrentModificationError(this); 70 throw new core.ConcurrentModificationError(this);
71 } 71 }
72 } 72 }
73 return false; 73 return false;
74 } 74 }
75 [core.$firstWhere](test, opts) { 75 [core.$firstWhere](test, opts) {
76 dart.as(test, dart.functionType(core.bool, [E]));
76 let orElse = opts && 'orElse' in opts ? opts.orElse : null; 77 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
78 dart.as(orElse, dart.functionType(E, []));
77 let length = this[core.$length]; 79 let length = this[core.$length];
78 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 80 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
79 let element = this[core.$elementAt](i); 81 let element = this[core.$elementAt](i);
80 if (test(element)) 82 if (test(element))
81 return element; 83 return element;
82 if (length != this[core.$length]) { 84 if (length != this[core.$length]) {
83 throw new core.ConcurrentModificationError(this); 85 throw new core.ConcurrentModificationError(this);
84 } 86 }
85 } 87 }
86 if (orElse != null) 88 if (orElse != null)
87 return orElse(); 89 return orElse();
88 throw IterableElementError.noElement(); 90 throw IterableElementError.noElement();
89 } 91 }
90 [core.$lastWhere](test, opts) { 92 [core.$lastWhere](test, opts) {
93 dart.as(test, dart.functionType(core.bool, [E]));
91 let orElse = opts && 'orElse' in opts ? opts.orElse : null; 94 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
95 dart.as(orElse, dart.functionType(E, []));
92 let length = this[core.$length]; 96 let length = this[core.$length];
93 for (let i = dart.notNull(length) - 1; dart.notNull(i) >= 0; i = dart.no tNull(i) - 1) { 97 for (let i = dart.notNull(length) - 1; dart.notNull(i) >= 0; i = dart.no tNull(i) - 1) {
94 let element = this[core.$elementAt](i); 98 let element = this[core.$elementAt](i);
95 if (test(element)) 99 if (test(element))
96 return element; 100 return element;
97 if (length != this[core.$length]) { 101 if (length != this[core.$length]) {
98 throw new core.ConcurrentModificationError(this); 102 throw new core.ConcurrentModificationError(this);
99 } 103 }
100 } 104 }
101 if (orElse != null) 105 if (orElse != null)
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 [core.$contains](element) { 785 [core.$contains](element) {
782 return false; 786 return false;
783 } 787 }
784 [core.$every](test) { 788 [core.$every](test) {
785 return true; 789 return true;
786 } 790 }
787 [core.$any](test) { 791 [core.$any](test) {
788 return false; 792 return false;
789 } 793 }
790 [core.$firstWhere](test, opts) { 794 [core.$firstWhere](test, opts) {
795 dart.as(test, dart.functionType(core.bool, [E]));
791 let orElse = opts && 'orElse' in opts ? opts.orElse : null; 796 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
797 dart.as(orElse, dart.functionType(E, []));
792 if (orElse != null) 798 if (orElse != null)
793 return orElse(); 799 return orElse();
794 throw IterableElementError.noElement(); 800 throw IterableElementError.noElement();
795 } 801 }
796 [core.$lastWhere](test, opts) { 802 [core.$lastWhere](test, opts) {
803 dart.as(test, dart.functionType(core.bool, [E]));
797 let orElse = opts && 'orElse' in opts ? opts.orElse : null; 804 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
805 dart.as(orElse, dart.functionType(E, []));
798 if (orElse != null) 806 if (orElse != null)
799 return orElse(); 807 return orElse();
800 throw IterableElementError.noElement(); 808 throw IterableElementError.noElement();
801 } 809 }
802 [core.$singleWhere](test, opts) { 810 [core.$singleWhere](test, opts) {
811 dart.as(test, dart.functionType(core.bool, [E]));
803 let orElse = opts && 'orElse' in opts ? opts.orElse : null; 812 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
813 dart.as(orElse, dart.functionType(E, []));
804 if (orElse != null) 814 if (orElse != null)
805 return orElse(); 815 return orElse();
806 throw IterableElementError.noElement(); 816 throw IterableElementError.noElement();
807 } 817 }
808 [core.$join](separator) { 818 [core.$join](separator) {
809 if (separator === void 0) 819 if (separator === void 0)
810 separator = ""; 820 separator = "";
811 return ""; 821 return "";
812 } 822 }
813 [core.$where](test) { 823 [core.$where](test) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 let __CastType6 = dart.typedef('__CastType6', () => dart.functionType(core.b ool, [T])); 1273 let __CastType6 = dart.typedef('__CastType6', () => dart.functionType(core.b ool, [T]));
1264 return __CastType6; 1274 return __CastType6;
1265 }); 1275 });
1266 let __CastType6 = __CastType6$(); 1276 let __CastType6 = __CastType6$();
1267 let FixedLengthListMixin$ = dart.generic(function(E) { 1277 let FixedLengthListMixin$ = dart.generic(function(E) {
1268 class FixedLengthListMixin extends core.Object { 1278 class FixedLengthListMixin extends core.Object {
1269 set length(newLength) { 1279 set length(newLength) {
1270 throw new core.UnsupportedError("Cannot change the length of a fixed-len gth list"); 1280 throw new core.UnsupportedError("Cannot change the length of a fixed-len gth list");
1271 } 1281 }
1272 add(value) { 1282 add(value) {
1283 dart.as(value, E);
1273 throw new core.UnsupportedError("Cannot add to a fixed-length list"); 1284 throw new core.UnsupportedError("Cannot add to a fixed-length list");
1274 } 1285 }
1275 insert(index, value) { 1286 insert(index, value) {
1287 dart.as(value, E);
1276 throw new core.UnsupportedError("Cannot add to a fixed-length list"); 1288 throw new core.UnsupportedError("Cannot add to a fixed-length list");
1277 } 1289 }
1278 insertAll(at, iterable) { 1290 insertAll(at, iterable) {
1279 throw new core.UnsupportedError("Cannot add to a fixed-length list"); 1291 throw new core.UnsupportedError("Cannot add to a fixed-length list");
1280 } 1292 }
1281 addAll(iterable) { 1293 addAll(iterable) {
1282 throw new core.UnsupportedError("Cannot add to a fixed-length list"); 1294 throw new core.UnsupportedError("Cannot add to a fixed-length list");
1283 } 1295 }
1284 remove(element) { 1296 remove(element) {
1285 throw new core.UnsupportedError("Cannot remove from a fixed-length list" ); 1297 throw new core.UnsupportedError("Cannot remove from a fixed-length list" );
(...skipping 19 matching lines...) Expand all
1305 replaceRange(start, end, iterable) { 1317 replaceRange(start, end, iterable) {
1306 throw new core.UnsupportedError("Cannot remove from a fixed-length list" ); 1318 throw new core.UnsupportedError("Cannot remove from a fixed-length list" );
1307 } 1319 }
1308 } 1320 }
1309 return FixedLengthListMixin; 1321 return FixedLengthListMixin;
1310 }); 1322 });
1311 let FixedLengthListMixin = FixedLengthListMixin$(); 1323 let FixedLengthListMixin = FixedLengthListMixin$();
1312 let UnmodifiableListMixin$ = dart.generic(function(E) { 1324 let UnmodifiableListMixin$ = dart.generic(function(E) {
1313 class UnmodifiableListMixin extends core.Object { 1325 class UnmodifiableListMixin extends core.Object {
1314 [core.$set](index, value) { 1326 [core.$set](index, value) {
1327 dart.as(value, E);
1315 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1328 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1316 } 1329 }
1317 set [core.$length](newLength) { 1330 set [core.$length](newLength) {
1318 throw new core.UnsupportedError("Cannot change the length of an unmodifi able list"); 1331 throw new core.UnsupportedError("Cannot change the length of an unmodifi able list");
1319 } 1332 }
1320 [core.$setAll](at, iterable) { 1333 [core.$setAll](at, iterable) {
1321 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1334 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1322 } 1335 }
1323 [core.$add](value) { 1336 [core.$add](value) {
1337 dart.as(value, E);
1324 throw new core.UnsupportedError("Cannot add to an unmodifiable list"); 1338 throw new core.UnsupportedError("Cannot add to an unmodifiable list");
1325 } 1339 }
1326 [core.$insert](index, value) { 1340 [core.$insert](index, value) {
1341 dart.as(value, E);
1327 throw new core.UnsupportedError("Cannot add to an unmodifiable list"); 1342 throw new core.UnsupportedError("Cannot add to an unmodifiable list");
1328 } 1343 }
1329 [core.$insertAll](at, iterable) { 1344 [core.$insertAll](at, iterable) {
1330 throw new core.UnsupportedError("Cannot add to an unmodifiable list"); 1345 throw new core.UnsupportedError("Cannot add to an unmodifiable list");
1331 } 1346 }
1332 [core.$addAll](iterable) { 1347 [core.$addAll](iterable) {
1333 throw new core.UnsupportedError("Cannot add to an unmodifiable list"); 1348 throw new core.UnsupportedError("Cannot add to an unmodifiable list");
1334 } 1349 }
1335 [core.$remove](element) { 1350 [core.$remove](element) {
1336 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1351 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1337 } 1352 }
1338 [core.$removeWhere](test) { 1353 [core.$removeWhere](test) {
1339 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1354 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1340 } 1355 }
1341 [core.$retainWhere](test) { 1356 [core.$retainWhere](test) {
1342 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1357 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1343 } 1358 }
1344 [core.$sort](compare) { 1359 [core.$sort](compare) {
1345 if (compare === void 0) 1360 if (compare === void 0)
1346 compare = null; 1361 compare = null;
1362 dart.as(compare, core.Comparator$(E));
1347 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1363 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1348 } 1364 }
1349 [core.$shuffle](random) { 1365 [core.$shuffle](random) {
1350 if (random === void 0) 1366 if (random === void 0)
1351 random = null; 1367 random = null;
1352 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1368 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1353 } 1369 }
1354 [core.$clear]() { 1370 [core.$clear]() {
1355 throw new core.UnsupportedError("Cannot clear an unmodifiable list"); 1371 throw new core.UnsupportedError("Cannot clear an unmodifiable list");
1356 } 1372 }
1357 [core.$removeAt](index) { 1373 [core.$removeAt](index) {
1358 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1374 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1359 } 1375 }
1360 [core.$removeLast]() { 1376 [core.$removeLast]() {
1361 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1377 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1362 } 1378 }
1363 [core.$setRange](start, end, iterable, skipCount) { 1379 [core.$setRange](start, end, iterable, skipCount) {
1380 dart.as(iterable, core.Iterable$(E));
1364 if (skipCount === void 0) 1381 if (skipCount === void 0)
1365 skipCount = 0; 1382 skipCount = 0;
1366 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1383 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1367 } 1384 }
1368 [core.$removeRange](start, end) { 1385 [core.$removeRange](start, end) {
1369 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1386 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1370 } 1387 }
1371 [core.$replaceRange](start, end, iterable) { 1388 [core.$replaceRange](start, end, iterable) {
1372 throw new core.UnsupportedError("Cannot remove from an unmodifiable list "); 1389 throw new core.UnsupportedError("Cannot remove from an unmodifiable list ");
1373 } 1390 }
1374 [core.$fillRange](start, end, fillValue) { 1391 [core.$fillRange](start, end, fillValue) {
1375 if (fillValue === void 0) 1392 if (fillValue === void 0)
1376 fillValue = null; 1393 fillValue = null;
1394 dart.as(fillValue, E);
1377 throw new core.UnsupportedError("Cannot modify an unmodifiable list"); 1395 throw new core.UnsupportedError("Cannot modify an unmodifiable list");
1378 } 1396 }
1379 } 1397 }
1380 UnmodifiableListMixin[dart.implements] = () => [core.List$(E)]; 1398 UnmodifiableListMixin[dart.implements] = () => [core.List$(E)];
1381 return UnmodifiableListMixin; 1399 return UnmodifiableListMixin;
1382 }); 1400 });
1383 let UnmodifiableListMixin = UnmodifiableListMixin$(); 1401 let UnmodifiableListMixin = UnmodifiableListMixin$();
1384 let FixedLengthListBase$ = dart.generic(function(E) { 1402 let FixedLengthListBase$ = dart.generic(function(E) {
1385 class FixedLengthListBase extends dart.mixin(collection.ListBase$(E), FixedL engthListMixin$(E)) {} 1403 class FixedLengthListBase extends dart.mixin(collection.ListBase$(E), FixedL engthListMixin$(E)) {}
1386 return FixedLengthListBase; 1404 return FixedLengthListBase;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 forEach(f) { 1456 forEach(f) {
1439 let length = this[_values][core.$length]; 1457 let length = this[_values][core.$length];
1440 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 1458 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
1441 f(i, this[_values][core.$get](i)); 1459 f(i, this[_values][core.$get](i));
1442 if (length != this[_values][core.$length]) { 1460 if (length != this[_values][core.$length]) {
1443 throw new core.ConcurrentModificationError(this[_values]); 1461 throw new core.ConcurrentModificationError(this[_values]);
1444 } 1462 }
1445 } 1463 }
1446 } 1464 }
1447 set(key, value) { 1465 set(key, value) {
1466 dart.as(value, E);
1448 throw new core.UnsupportedError("Cannot modify an unmodifiable map"); 1467 throw new core.UnsupportedError("Cannot modify an unmodifiable map");
1449 } 1468 }
1450 putIfAbsent(key, ifAbsent) { 1469 putIfAbsent(key, ifAbsent) {
1451 throw new core.UnsupportedError("Cannot modify an unmodifiable map"); 1470 throw new core.UnsupportedError("Cannot modify an unmodifiable map");
1452 } 1471 }
1453 remove(key) { 1472 remove(key) {
1454 throw new core.UnsupportedError("Cannot modify an unmodifiable map"); 1473 throw new core.UnsupportedError("Cannot modify an unmodifiable map");
1455 } 1474 }
1456 clear() { 1475 clear() {
1457 throw new core.UnsupportedError("Cannot modify an unmodifiable map"); 1476 throw new core.UnsupportedError("Cannot modify an unmodifiable map");
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 exports.ReversedListIterable = ReversedListIterable; 1981 exports.ReversedListIterable = ReversedListIterable;
1963 exports.UnmodifiableListError = UnmodifiableListError; 1982 exports.UnmodifiableListError = UnmodifiableListError;
1964 exports.NonGrowableListError = NonGrowableListError; 1983 exports.NonGrowableListError = NonGrowableListError;
1965 exports.makeListFixedLength = makeListFixedLength; 1984 exports.makeListFixedLength = makeListFixedLength;
1966 exports.Lists = Lists; 1985 exports.Lists = Lists;
1967 exports.printToConsole = printToConsole; 1986 exports.printToConsole = printToConsole;
1968 exports.Sort = Sort; 1987 exports.Sort = Sort;
1969 exports.Symbol = Symbol; 1988 exports.Symbol = Symbol;
1970 exports.POWERS_OF_TEN = POWERS_OF_TEN; 1989 exports.POWERS_OF_TEN = POWERS_OF_TEN;
1971 })(_internal || (_internal = {})); 1990 })(_internal || (_internal = {}));
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/runtime/dart/collection.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698