| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import 'package:analyzer/src/generated/source.dart'; | 22 import 'package:analyzer/src/generated/source.dart'; |
| 23 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 23 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
| 24 import 'package:analyzer/src/summary/idl.dart'; | 24 import 'package:analyzer/src/summary/idl.dart'; |
| 25 import 'package:analyzer/src/summary/resynthesize.dart'; | 25 import 'package:analyzer/src/summary/resynthesize.dart'; |
| 26 import 'package:test/test.dart'; | 26 import 'package:test/test.dart'; |
| 27 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 27 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 28 | 28 |
| 29 import '../../generated/test_support.dart'; | 29 import '../../generated/test_support.dart'; |
| 30 import '../abstract_single_unit.dart'; | 30 import '../abstract_single_unit.dart'; |
| 31 import '../context/abstract_context.dart'; | 31 import '../context/abstract_context.dart'; |
| 32 import 'element_text.dart'; |
| 32 | 33 |
| 33 /** | 34 /** |
| 34 * Abstract base class for resynthesizing and comparing elements. | 35 * Abstract base class for resynthesizing and comparing elements. |
| 36 * |
| 37 * The return type separator: → |
| 35 */ | 38 */ |
| 36 abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { | 39 abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { |
| 37 Set<Source> otherLibrarySources = new Set<Source>(); | 40 Set<Source> otherLibrarySources = new Set<Source>(); |
| 38 | 41 |
| 39 /** | 42 /** |
| 40 * Names of variables which have initializers that are not valid constants, | 43 * Names of variables which have initializers that are not valid constants, |
| 41 * so they are not resynthesized. | 44 * so they are not resynthesized. |
| 42 */ | 45 */ |
| 43 Set<String> variablesWithNotConstInitializers = new Set<String>(); | 46 Set<String> variablesWithNotConstInitializers = new Set<String>(); |
| 44 | 47 |
| 45 /** | 48 /** |
| 46 * Names that cannot be resolved, e.g. because of duplicate declaration. | 49 * Names that cannot be resolved, e.g. because of duplicate declaration. |
| 47 */ | 50 */ |
| 48 Set<String> namesThatCannotBeResolved = new Set<String>(); | 51 Set<String> namesThatCannotBeResolved = new Set<String>(); |
| 49 | 52 |
| 50 /** | 53 /** |
| 51 * Tests may set this to `true` to indicate that a missing file at the time of | 54 * Tests may set this to `true` to indicate that a missing file at the time of |
| 52 * summary resynthesis shouldn't trigger an error. | 55 * summary resynthesis shouldn't trigger an error. |
| 53 */ | 56 */ |
| 54 bool allowMissingFiles = false; | 57 bool allowMissingFiles = false; |
| 55 | 58 |
| 59 /** |
| 60 * Return `true` if resynthesizing should be done is strong mode. |
| 61 */ |
| 62 bool get isStrongMode; |
| 63 |
| 56 void addLibrary(String uri) { | 64 void addLibrary(String uri) { |
| 57 otherLibrarySources.add(context.sourceFactory.forUri(uri)); | 65 otherLibrarySources.add(context.sourceFactory.forUri(uri)); |
| 58 } | 66 } |
| 59 | 67 |
| 60 Source addLibrarySource(String filePath, String contents) { | 68 Source addLibrarySource(String filePath, String contents) { |
| 61 Source source = addSource(filePath, contents); | 69 Source source = addSource(filePath, contents); |
| 62 otherLibrarySources.add(source); | 70 otherLibrarySources.add(source); |
| 63 return source; | 71 return source; |
| 64 } | 72 } |
| 65 | 73 |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 LibraryElementImpl checkLibrary(String text, | 1318 LibraryElementImpl checkLibrary(String text, |
| 1311 {bool allowErrors: false, bool dumpSummaries: false}); | 1319 {bool allowErrors: false, bool dumpSummaries: false}); |
| 1312 | 1320 |
| 1313 /** | 1321 /** |
| 1314 * Return a [SummaryResynthesizer] to resynthesize the library with the | 1322 * Return a [SummaryResynthesizer] to resynthesize the library with the |
| 1315 * given [librarySource]. | 1323 * given [librarySource]. |
| 1316 */ | 1324 */ |
| 1317 SummaryResynthesizer encodeDecodeLibrarySource(Source librarySource); | 1325 SummaryResynthesizer encodeDecodeLibrarySource(Source librarySource); |
| 1318 | 1326 |
| 1319 fail_library_hasExtUri() { | 1327 fail_library_hasExtUri() { |
| 1320 checkLibrary('import "dart-ext:doesNotExist.dart";'); | 1328 var library = checkLibrary('import "dart-ext:doesNotExist.dart";'); |
| 1329 if (isStrongMode) { |
| 1330 checkElementText( |
| 1331 library, |
| 1332 r''' |
| 1333 '''); |
| 1334 } else { |
| 1335 checkElementText( |
| 1336 library, |
| 1337 r''' |
| 1338 '''); |
| 1339 } |
| 1321 } | 1340 } |
| 1322 | 1341 |
| 1323 test_class_abstract() { | 1342 test_class_abstract() { |
| 1324 checkLibrary('abstract class C {}'); | 1343 var library = checkLibrary('abstract class C {}'); |
| 1344 if (isStrongMode) { |
| 1345 checkElementText( |
| 1346 library, |
| 1347 r''' |
| 1348 abstract class C { |
| 1349 } |
| 1350 '''); |
| 1351 } else { |
| 1352 checkElementText( |
| 1353 library, |
| 1354 r''' |
| 1355 abstract class C { |
| 1356 } |
| 1357 '''); |
| 1358 } |
| 1325 } | 1359 } |
| 1326 | 1360 |
| 1327 test_class_alias() { | 1361 test_class_alias() { |
| 1328 checkLibrary('class C = D with E, F; class D {} class E {} class F {}'); | 1362 var library = |
| 1363 checkLibrary('class C = D with E, F; class D {} class E {} class F {}'); |
| 1364 if (isStrongMode) { |
| 1365 checkElementText( |
| 1366 library, |
| 1367 r''' |
| 1368 class alias C extends D with E, F { |
| 1369 synthetic C() = D; |
| 1370 } |
| 1371 class D { |
| 1372 } |
| 1373 class E { |
| 1374 } |
| 1375 class F { |
| 1376 } |
| 1377 '''); |
| 1378 } else { |
| 1379 checkElementText( |
| 1380 library, |
| 1381 r''' |
| 1382 class alias C extends D with E, F { |
| 1383 synthetic C() = D; |
| 1384 } |
| 1385 class D { |
| 1386 } |
| 1387 class E { |
| 1388 } |
| 1389 class F { |
| 1390 } |
| 1391 '''); |
| 1392 } |
| 1329 } | 1393 } |
| 1330 | 1394 |
| 1331 test_class_alias_abstract() { | 1395 test_class_alias_abstract() { |
| 1332 checkLibrary('abstract class C = D with E; class D {} class E {}'); | 1396 var library = |
| 1397 checkLibrary('abstract class C = D with E; class D {} class E {}'); |
| 1398 if (isStrongMode) { |
| 1399 checkElementText( |
| 1400 library, |
| 1401 r''' |
| 1402 abstract class alias C extends D with E { |
| 1403 synthetic C() = D; |
| 1404 } |
| 1405 class D { |
| 1406 } |
| 1407 class E { |
| 1408 } |
| 1409 '''); |
| 1410 } else { |
| 1411 checkElementText( |
| 1412 library, |
| 1413 r''' |
| 1414 abstract class alias C extends D with E { |
| 1415 synthetic C() = D; |
| 1416 } |
| 1417 class D { |
| 1418 } |
| 1419 class E { |
| 1420 } |
| 1421 '''); |
| 1422 } |
| 1333 } | 1423 } |
| 1334 | 1424 |
| 1335 test_class_alias_documented() { | 1425 test_class_alias_documented() { |
| 1336 checkLibrary(''' | 1426 var library = checkLibrary(''' |
| 1337 // Extra comment so doc comment offset != 0 | 1427 // Extra comment so doc comment offset != 0 |
| 1338 /** | 1428 /** |
| 1339 * Docs | 1429 * Docs |
| 1340 */ | 1430 */ |
| 1341 class C = D with E; | 1431 class C = D with E; |
| 1342 | 1432 |
| 1343 class D {} | 1433 class D {} |
| 1344 class E {}'''); | 1434 class E {}'''); |
| 1435 if (isStrongMode) { |
| 1436 checkElementText( |
| 1437 library, |
| 1438 r''' |
| 1439 /** |
| 1440 * Docs |
| 1441 */ |
| 1442 class alias C extends D with E { |
| 1443 synthetic C() = D; |
| 1444 } |
| 1445 class D { |
| 1446 } |
| 1447 class E { |
| 1448 } |
| 1449 '''); |
| 1450 } else { |
| 1451 checkElementText( |
| 1452 library, |
| 1453 r''' |
| 1454 /** |
| 1455 * Docs |
| 1456 */ |
| 1457 class alias C extends D with E { |
| 1458 synthetic C() = D; |
| 1459 } |
| 1460 class D { |
| 1461 } |
| 1462 class E { |
| 1463 } |
| 1464 '''); |
| 1465 } |
| 1345 } | 1466 } |
| 1346 | 1467 |
| 1347 test_class_alias_with_forwarding_constructors() { | 1468 test_class_alias_with_forwarding_constructors() { |
| 1348 addLibrarySource( | 1469 addLibrarySource( |
| 1349 '/a.dart', | 1470 '/a.dart', |
| 1350 ''' | 1471 ''' |
| 1351 class Base { | 1472 class Base { |
| 1352 Base._priv(); | 1473 Base._priv(); |
| 1353 Base(); | 1474 Base(); |
| 1354 Base.noArgs(); | 1475 Base.noArgs(); |
| 1355 Base.requiredArg(x); | 1476 Base.requiredArg(x); |
| 1356 Base.positionalArg([x]); | 1477 Base.positionalArg([x]); |
| 1357 Base.namedArg({x}); | 1478 Base.namedArg({x}); |
| 1358 factory Base.fact() => null; | 1479 factory Base.fact() => null; |
| 1359 factory Base.fact2() = Base.noArgs; | 1480 factory Base.fact2() = Base.noArgs; |
| 1360 } | 1481 } |
| 1361 '''); | 1482 '''); |
| 1362 checkLibrary(''' | 1483 var library = checkLibrary(''' |
| 1363 import "a.dart"; | 1484 import "a.dart"; |
| 1364 class M {} | 1485 class M {} |
| 1365 class MixinApp = Base with M; | 1486 class MixinApp = Base with M; |
| 1366 '''); | 1487 '''); |
| 1488 if (isStrongMode) { |
| 1489 checkElementText( |
| 1490 library, |
| 1491 r''' |
| 1492 import 'a.dart'; |
| 1493 class M { |
| 1494 } |
| 1495 class alias MixinApp extends Base with M { |
| 1496 synthetic MixinApp._priv() = Base._priv; |
| 1497 synthetic MixinApp() = Base; |
| 1498 synthetic MixinApp.noArgs() = Base.noArgs; |
| 1499 synthetic MixinApp.requiredArg(dynamic x) = Base.requiredArg; |
| 1500 synthetic MixinApp.fact() = Base.fact; |
| 1501 synthetic MixinApp.fact2() = Base.fact2; |
| 1502 } |
| 1503 '''); |
| 1504 } else { |
| 1505 checkElementText( |
| 1506 library, |
| 1507 r''' |
| 1508 import 'a.dart'; |
| 1509 class M { |
| 1510 } |
| 1511 class alias MixinApp extends Base with M { |
| 1512 synthetic MixinApp._priv() = Base._priv; |
| 1513 synthetic MixinApp() = Base; |
| 1514 synthetic MixinApp.noArgs() = Base.noArgs; |
| 1515 synthetic MixinApp.requiredArg(dynamic x) = Base.requiredArg; |
| 1516 synthetic MixinApp.fact() = Base.fact; |
| 1517 synthetic MixinApp.fact2() = Base.fact2; |
| 1518 } |
| 1519 '''); |
| 1520 } |
| 1367 } | 1521 } |
| 1368 | 1522 |
| 1369 test_class_alias_with_forwarding_constructors_type_substitution() { | 1523 test_class_alias_with_forwarding_constructors_type_substitution() { |
| 1370 checkLibrary(''' | 1524 var library = checkLibrary(''' |
| 1371 class Base<T> { | 1525 class Base<T> { |
| 1372 Base.ctor(T t, List<T> l); | 1526 Base.ctor(T t, List<T> l); |
| 1373 } | 1527 } |
| 1374 class M {} | 1528 class M {} |
| 1375 class MixinApp = Base with M; | 1529 class MixinApp = Base with M; |
| 1376 '''); | 1530 '''); |
| 1531 if (isStrongMode) { |
| 1532 checkElementText( |
| 1533 library, |
| 1534 r''' |
| 1535 class Base<T> { |
| 1536 Base.ctor(T t, List<T> l); |
| 1537 } |
| 1538 class M { |
| 1539 } |
| 1540 class alias MixinApp extends Base<dynamic> with M { |
| 1541 synthetic MixinApp.ctor(dynamic t, List<dynamic> l) = Base<T>.ctor; |
| 1542 } |
| 1543 '''); |
| 1544 } else { |
| 1545 checkElementText( |
| 1546 library, |
| 1547 r''' |
| 1548 class Base<T> { |
| 1549 Base.ctor(T t, List<T> l); |
| 1550 } |
| 1551 class M { |
| 1552 } |
| 1553 class alias MixinApp extends Base<dynamic> with M { |
| 1554 synthetic MixinApp.ctor(dynamic t, List<dynamic> l) = Base<T>.ctor; |
| 1555 } |
| 1556 '''); |
| 1557 } |
| 1377 } | 1558 } |
| 1378 | 1559 |
| 1379 test_class_alias_with_forwarding_constructors_type_substitution_complex() { | 1560 test_class_alias_with_forwarding_constructors_type_substitution_complex() { |
| 1380 checkLibrary(''' | 1561 var library = checkLibrary(''' |
| 1381 class Base<T> { | 1562 class Base<T> { |
| 1382 Base.ctor(T t, List<T> l); | 1563 Base.ctor(T t, List<T> l); |
| 1383 } | 1564 } |
| 1384 class M {} | 1565 class M {} |
| 1385 class MixinApp<U> = Base<List<U>> with M; | 1566 class MixinApp<U> = Base<List<U>> with M; |
| 1386 '''); | 1567 '''); |
| 1568 if (isStrongMode) { |
| 1569 checkElementText( |
| 1570 library, |
| 1571 r''' |
| 1572 class Base<T> { |
| 1573 Base.ctor(T t, List<T> l); |
| 1574 } |
| 1575 class M { |
| 1576 } |
| 1577 class alias MixinApp<U> extends Base<List<U>> with M { |
| 1578 synthetic MixinApp.ctor(List<U> t, List<List<U>> l) = Base<T>.ctor; |
| 1579 } |
| 1580 '''); |
| 1581 } else { |
| 1582 checkElementText( |
| 1583 library, |
| 1584 r''' |
| 1585 class Base<T> { |
| 1586 Base.ctor(T t, List<T> l); |
| 1587 } |
| 1588 class M { |
| 1589 } |
| 1590 class alias MixinApp<U> extends Base<List<U>> with M { |
| 1591 synthetic MixinApp.ctor(List<U> t, List<List<U>> l) = Base<T>.ctor; |
| 1592 } |
| 1593 '''); |
| 1594 } |
| 1387 } | 1595 } |
| 1388 | 1596 |
| 1389 test_class_alias_with_mixin_members() { | 1597 test_class_alias_with_mixin_members() { |
| 1390 checkLibrary(''' | 1598 var library = checkLibrary(''' |
| 1391 class C = D with E; | 1599 class C = D with E; |
| 1392 class D {} | 1600 class D {} |
| 1393 class E { | 1601 class E { |
| 1394 int get a => null; | 1602 int get a => null; |
| 1395 void set b(int i) {} | 1603 void set b(int i) {} |
| 1396 void f() {} | 1604 void f() {} |
| 1397 int x; | 1605 int x; |
| 1398 }'''); | 1606 }'''); |
| 1607 if (isStrongMode) { |
| 1608 checkElementText( |
| 1609 library, |
| 1610 r''' |
| 1611 class alias C extends D with E { |
| 1612 synthetic C() = D; |
| 1613 } |
| 1614 class D { |
| 1615 } |
| 1616 class E { |
| 1617 int x; |
| 1618 int get a {} |
| 1619 void set b(int i) {} |
| 1620 void f() {} |
| 1621 } |
| 1622 '''); |
| 1623 } else { |
| 1624 checkElementText( |
| 1625 library, |
| 1626 r''' |
| 1627 class alias C extends D with E { |
| 1628 synthetic C() = D; |
| 1629 } |
| 1630 class D { |
| 1631 } |
| 1632 class E { |
| 1633 int x; |
| 1634 int get a {} |
| 1635 void set b(int i) {} |
| 1636 void f() {} |
| 1637 } |
| 1638 '''); |
| 1639 } |
| 1399 } | 1640 } |
| 1400 | 1641 |
| 1401 test_class_constructor_const() { | 1642 test_class_constructor_const() { |
| 1402 checkLibrary('class C { const C(); }'); | 1643 var library = checkLibrary('class C { const C(); }'); |
| 1644 if (isStrongMode) { |
| 1645 checkElementText( |
| 1646 library, |
| 1647 r''' |
| 1648 class C { |
| 1649 const C(); |
| 1650 } |
| 1651 '''); |
| 1652 } else { |
| 1653 checkElementText( |
| 1654 library, |
| 1655 r''' |
| 1656 class C { |
| 1657 const C(); |
| 1658 } |
| 1659 '''); |
| 1660 } |
| 1403 } | 1661 } |
| 1404 | 1662 |
| 1405 test_class_constructor_const_external() { | 1663 test_class_constructor_const_external() { |
| 1406 checkLibrary('class C { external const C(); }'); | 1664 var library = checkLibrary('class C { external const C(); }'); |
| 1665 if (isStrongMode) { |
| 1666 checkElementText( |
| 1667 library, |
| 1668 r''' |
| 1669 class C { |
| 1670 external const C(); |
| 1671 } |
| 1672 '''); |
| 1673 } else { |
| 1674 checkElementText( |
| 1675 library, |
| 1676 r''' |
| 1677 class C { |
| 1678 external const C(); |
| 1679 } |
| 1680 '''); |
| 1681 } |
| 1407 } | 1682 } |
| 1408 | 1683 |
| 1409 test_class_constructor_explicit_named() { | 1684 test_class_constructor_explicit_named() { |
| 1410 checkLibrary('class C { C.foo(); }'); | 1685 var library = checkLibrary('class C { C.foo(); }'); |
| 1686 if (isStrongMode) { |
| 1687 checkElementText( |
| 1688 library, |
| 1689 r''' |
| 1690 class C { |
| 1691 C.foo(); |
| 1692 } |
| 1693 '''); |
| 1694 } else { |
| 1695 checkElementText( |
| 1696 library, |
| 1697 r''' |
| 1698 class C { |
| 1699 C.foo(); |
| 1700 } |
| 1701 '''); |
| 1702 } |
| 1411 } | 1703 } |
| 1412 | 1704 |
| 1413 test_class_constructor_explicit_type_params() { | 1705 test_class_constructor_explicit_type_params() { |
| 1414 checkLibrary('class C<T, U> { C(); }'); | 1706 var library = checkLibrary('class C<T, U> { C(); }'); |
| 1707 if (isStrongMode) { |
| 1708 checkElementText( |
| 1709 library, |
| 1710 r''' |
| 1711 class C<T, U> { |
| 1712 C(); |
| 1713 } |
| 1714 '''); |
| 1715 } else { |
| 1716 checkElementText( |
| 1717 library, |
| 1718 r''' |
| 1719 class C<T, U> { |
| 1720 C(); |
| 1721 } |
| 1722 '''); |
| 1723 } |
| 1415 } | 1724 } |
| 1416 | 1725 |
| 1417 test_class_constructor_explicit_unnamed() { | 1726 test_class_constructor_explicit_unnamed() { |
| 1418 checkLibrary('class C { C(); }'); | 1727 var library = checkLibrary('class C { C(); }'); |
| 1728 if (isStrongMode) { |
| 1729 checkElementText( |
| 1730 library, |
| 1731 r''' |
| 1732 class C { |
| 1733 C(); |
| 1734 } |
| 1735 '''); |
| 1736 } else { |
| 1737 checkElementText( |
| 1738 library, |
| 1739 r''' |
| 1740 class C { |
| 1741 C(); |
| 1742 } |
| 1743 '''); |
| 1744 } |
| 1419 } | 1745 } |
| 1420 | 1746 |
| 1421 test_class_constructor_external() { | 1747 test_class_constructor_external() { |
| 1422 checkLibrary('class C { external C(); }'); | 1748 var library = checkLibrary('class C { external C(); }'); |
| 1749 if (isStrongMode) { |
| 1750 checkElementText( |
| 1751 library, |
| 1752 r''' |
| 1753 class C { |
| 1754 external C(); |
| 1755 } |
| 1756 '''); |
| 1757 } else { |
| 1758 checkElementText( |
| 1759 library, |
| 1760 r''' |
| 1761 class C { |
| 1762 external C(); |
| 1763 } |
| 1764 '''); |
| 1765 } |
| 1423 } | 1766 } |
| 1424 | 1767 |
| 1425 test_class_constructor_factory() { | 1768 test_class_constructor_factory() { |
| 1426 checkLibrary('class C { factory C() => null; }'); | 1769 var library = checkLibrary('class C { factory C() => null; }'); |
| 1770 if (isStrongMode) { |
| 1771 checkElementText( |
| 1772 library, |
| 1773 r''' |
| 1774 class C { |
| 1775 factory C(); |
| 1776 } |
| 1777 '''); |
| 1778 } else { |
| 1779 checkElementText( |
| 1780 library, |
| 1781 r''' |
| 1782 class C { |
| 1783 factory C(); |
| 1784 } |
| 1785 '''); |
| 1786 } |
| 1427 } | 1787 } |
| 1428 | 1788 |
| 1429 test_class_constructor_field_formal_dynamic_dynamic() { | 1789 test_class_constructor_field_formal_dynamic_dynamic() { |
| 1430 checkLibrary('class C { dynamic x; C(dynamic this.x); }'); | 1790 var library = checkLibrary('class C { dynamic x; C(dynamic this.x); }'); |
| 1791 if (isStrongMode) { |
| 1792 checkElementText( |
| 1793 library, |
| 1794 r''' |
| 1795 class C { |
| 1796 dynamic x; |
| 1797 C(dynamic this.x); |
| 1798 } |
| 1799 '''); |
| 1800 } else { |
| 1801 checkElementText( |
| 1802 library, |
| 1803 r''' |
| 1804 class C { |
| 1805 dynamic x; |
| 1806 C(dynamic this.x); |
| 1807 } |
| 1808 '''); |
| 1809 } |
| 1431 } | 1810 } |
| 1432 | 1811 |
| 1433 test_class_constructor_field_formal_dynamic_typed() { | 1812 test_class_constructor_field_formal_dynamic_typed() { |
| 1434 checkLibrary('class C { dynamic x; C(int this.x); }'); | 1813 var library = checkLibrary('class C { dynamic x; C(int this.x); }'); |
| 1814 if (isStrongMode) { |
| 1815 checkElementText( |
| 1816 library, |
| 1817 r''' |
| 1818 class C { |
| 1819 dynamic x; |
| 1820 C(int this.x); |
| 1821 } |
| 1822 '''); |
| 1823 } else { |
| 1824 checkElementText( |
| 1825 library, |
| 1826 r''' |
| 1827 class C { |
| 1828 dynamic x; |
| 1829 C(int this.x); |
| 1830 } |
| 1831 '''); |
| 1832 } |
| 1435 } | 1833 } |
| 1436 | 1834 |
| 1437 test_class_constructor_field_formal_dynamic_untyped() { | 1835 test_class_constructor_field_formal_dynamic_untyped() { |
| 1438 checkLibrary('class C { dynamic x; C(this.x); }'); | 1836 var library = checkLibrary('class C { dynamic x; C(this.x); }'); |
| 1837 if (isStrongMode) { |
| 1838 checkElementText( |
| 1839 library, |
| 1840 r''' |
| 1841 class C { |
| 1842 dynamic x; |
| 1843 C(dynamic this.x); |
| 1844 } |
| 1845 '''); |
| 1846 } else { |
| 1847 checkElementText( |
| 1848 library, |
| 1849 r''' |
| 1850 class C { |
| 1851 dynamic x; |
| 1852 C(dynamic this.x); |
| 1853 } |
| 1854 '''); |
| 1855 } |
| 1439 } | 1856 } |
| 1440 | 1857 |
| 1441 test_class_constructor_field_formal_multiple_matching_fields() { | 1858 test_class_constructor_field_formal_multiple_matching_fields() { |
| 1442 // This is a compile-time error but it should still analyze consistently. | 1859 // This is a compile-time error but it should still analyze consistently. |
| 1443 checkLibrary('class C { C(this.x); int x; String x; }', allowErrors: true); | 1860 var library = checkLibrary('class C { C(this.x); int x; String x; }', |
| 1861 allowErrors: true); |
| 1862 if (isStrongMode) { |
| 1863 checkElementText( |
| 1864 library, |
| 1865 r''' |
| 1866 class C { |
| 1867 int x; |
| 1868 String x; |
| 1869 C(int this.x); |
| 1870 } |
| 1871 '''); |
| 1872 } else { |
| 1873 checkElementText( |
| 1874 library, |
| 1875 r''' |
| 1876 class C { |
| 1877 int x; |
| 1878 String x; |
| 1879 C(int this.x); |
| 1880 } |
| 1881 '''); |
| 1882 } |
| 1444 } | 1883 } |
| 1445 | 1884 |
| 1446 test_class_constructor_field_formal_no_matching_field() { | 1885 test_class_constructor_field_formal_no_matching_field() { |
| 1447 // This is a compile-time error but it should still analyze consistently. | 1886 // This is a compile-time error but it should still analyze consistently. |
| 1448 checkLibrary('class C { C(this.x); }', allowErrors: true); | 1887 var library = checkLibrary('class C { C(this.x); }', allowErrors: true); |
| 1888 if (isStrongMode) { |
| 1889 checkElementText( |
| 1890 library, |
| 1891 r''' |
| 1892 class C { |
| 1893 C(dynamic this.x); |
| 1894 } |
| 1895 '''); |
| 1896 } else { |
| 1897 checkElementText( |
| 1898 library, |
| 1899 r''' |
| 1900 class C { |
| 1901 C(dynamic this.x); |
| 1902 } |
| 1903 '''); |
| 1904 } |
| 1449 } | 1905 } |
| 1450 | 1906 |
| 1451 test_class_constructor_field_formal_typed_dynamic() { | 1907 test_class_constructor_field_formal_typed_dynamic() { |
| 1452 checkLibrary('class C { num x; C(dynamic this.x); }', allowErrors: true); | 1908 var library = checkLibrary('class C { num x; C(dynamic this.x); }', |
| 1909 allowErrors: true); |
| 1910 if (isStrongMode) { |
| 1911 checkElementText( |
| 1912 library, |
| 1913 r''' |
| 1914 class C { |
| 1915 num x; |
| 1916 C(dynamic this.x); |
| 1917 } |
| 1918 '''); |
| 1919 } else { |
| 1920 checkElementText( |
| 1921 library, |
| 1922 r''' |
| 1923 class C { |
| 1924 num x; |
| 1925 C(dynamic this.x); |
| 1926 } |
| 1927 '''); |
| 1928 } |
| 1453 } | 1929 } |
| 1454 | 1930 |
| 1455 test_class_constructor_field_formal_typed_typed() { | 1931 test_class_constructor_field_formal_typed_typed() { |
| 1456 checkLibrary('class C { num x; C(int this.x); }'); | 1932 var library = checkLibrary('class C { num x; C(int this.x); }'); |
| 1933 if (isStrongMode) { |
| 1934 checkElementText( |
| 1935 library, |
| 1936 r''' |
| 1937 class C { |
| 1938 num x; |
| 1939 C(int this.x); |
| 1940 } |
| 1941 '''); |
| 1942 } else { |
| 1943 checkElementText( |
| 1944 library, |
| 1945 r''' |
| 1946 class C { |
| 1947 num x; |
| 1948 C(int this.x); |
| 1949 } |
| 1950 '''); |
| 1951 } |
| 1457 } | 1952 } |
| 1458 | 1953 |
| 1459 test_class_constructor_field_formal_typed_untyped() { | 1954 test_class_constructor_field_formal_typed_untyped() { |
| 1460 checkLibrary('class C { num x; C(this.x); }'); | 1955 var library = checkLibrary('class C { num x; C(this.x); }'); |
| 1956 if (isStrongMode) { |
| 1957 checkElementText( |
| 1958 library, |
| 1959 r''' |
| 1960 class C { |
| 1961 num x; |
| 1962 C(num this.x); |
| 1963 } |
| 1964 '''); |
| 1965 } else { |
| 1966 checkElementText( |
| 1967 library, |
| 1968 r''' |
| 1969 class C { |
| 1970 num x; |
| 1971 C(num this.x); |
| 1972 } |
| 1973 '''); |
| 1974 } |
| 1461 } | 1975 } |
| 1462 | 1976 |
| 1463 test_class_constructor_field_formal_untyped_dynamic() { | 1977 test_class_constructor_field_formal_untyped_dynamic() { |
| 1464 checkLibrary('class C { var x; C(dynamic this.x); }'); | 1978 var library = checkLibrary('class C { var x; C(dynamic this.x); }'); |
| 1979 if (isStrongMode) { |
| 1980 checkElementText( |
| 1981 library, |
| 1982 r''' |
| 1983 class C { |
| 1984 dynamic x; |
| 1985 C(dynamic this.x); |
| 1986 } |
| 1987 '''); |
| 1988 } else { |
| 1989 checkElementText( |
| 1990 library, |
| 1991 r''' |
| 1992 class C { |
| 1993 dynamic x; |
| 1994 C(dynamic this.x); |
| 1995 } |
| 1996 '''); |
| 1997 } |
| 1465 } | 1998 } |
| 1466 | 1999 |
| 1467 test_class_constructor_field_formal_untyped_typed() { | 2000 test_class_constructor_field_formal_untyped_typed() { |
| 1468 checkLibrary('class C { var x; C(int this.x); }'); | 2001 var library = checkLibrary('class C { var x; C(int this.x); }'); |
| 2002 if (isStrongMode) { |
| 2003 checkElementText( |
| 2004 library, |
| 2005 r''' |
| 2006 class C { |
| 2007 dynamic x; |
| 2008 C(int this.x); |
| 2009 } |
| 2010 '''); |
| 2011 } else { |
| 2012 checkElementText( |
| 2013 library, |
| 2014 r''' |
| 2015 class C { |
| 2016 dynamic x; |
| 2017 C(int this.x); |
| 2018 } |
| 2019 '''); |
| 2020 } |
| 1469 } | 2021 } |
| 1470 | 2022 |
| 1471 test_class_constructor_field_formal_untyped_untyped() { | 2023 test_class_constructor_field_formal_untyped_untyped() { |
| 1472 checkLibrary('class C { var x; C(this.x); }'); | 2024 var library = checkLibrary('class C { var x; C(this.x); }'); |
| 2025 if (isStrongMode) { |
| 2026 checkElementText( |
| 2027 library, |
| 2028 r''' |
| 2029 class C { |
| 2030 dynamic x; |
| 2031 C(dynamic this.x); |
| 2032 } |
| 2033 '''); |
| 2034 } else { |
| 2035 checkElementText( |
| 2036 library, |
| 2037 r''' |
| 2038 class C { |
| 2039 dynamic x; |
| 2040 C(dynamic this.x); |
| 2041 } |
| 2042 '''); |
| 2043 } |
| 1473 } | 2044 } |
| 1474 | 2045 |
| 1475 test_class_constructor_fieldFormal_named_noDefault() { | 2046 test_class_constructor_fieldFormal_named_noDefault() { |
| 1476 checkLibrary('class C { int x; C({this.x}); }'); | 2047 var library = checkLibrary('class C { int x; C({this.x}); }'); |
| 2048 if (isStrongMode) { |
| 2049 checkElementText( |
| 2050 library, |
| 2051 r''' |
| 2052 class C { |
| 2053 int x; |
| 2054 C({int this.x}); |
| 2055 } |
| 2056 '''); |
| 2057 } else { |
| 2058 checkElementText( |
| 2059 library, |
| 2060 r''' |
| 2061 class C { |
| 2062 int x; |
| 2063 C({int this.x}); |
| 2064 } |
| 2065 '''); |
| 2066 } |
| 1477 } | 2067 } |
| 1478 | 2068 |
| 1479 test_class_constructor_fieldFormal_named_withDefault() { | 2069 test_class_constructor_fieldFormal_named_withDefault() { |
| 1480 checkLibrary('class C { int x; C({this.x: 42}); }'); | 2070 var library = checkLibrary('class C { int x; C({this.x: 42}); }'); |
| 2071 if (isStrongMode) { |
| 2072 checkElementText( |
| 2073 library, |
| 2074 r''' |
| 2075 class C { |
| 2076 int x; |
| 2077 C({int this.x}); |
| 2078 } |
| 2079 '''); |
| 2080 } else { |
| 2081 checkElementText( |
| 2082 library, |
| 2083 r''' |
| 2084 class C { |
| 2085 int x; |
| 2086 C({int this.x}); |
| 2087 } |
| 2088 '''); |
| 2089 } |
| 1481 } | 2090 } |
| 1482 | 2091 |
| 1483 test_class_constructor_fieldFormal_optional_noDefault() { | 2092 test_class_constructor_fieldFormal_optional_noDefault() { |
| 1484 checkLibrary('class C { int x; C([this.x]); }'); | 2093 var library = checkLibrary('class C { int x; C([this.x]); }'); |
| 2094 if (isStrongMode) { |
| 2095 checkElementText( |
| 2096 library, |
| 2097 r''' |
| 2098 class C { |
| 2099 int x; |
| 2100 C([int this.x]); |
| 2101 } |
| 2102 '''); |
| 2103 } else { |
| 2104 checkElementText( |
| 2105 library, |
| 2106 r''' |
| 2107 class C { |
| 2108 int x; |
| 2109 C([int this.x]); |
| 2110 } |
| 2111 '''); |
| 2112 } |
| 1485 } | 2113 } |
| 1486 | 2114 |
| 1487 test_class_constructor_fieldFormal_optional_withDefault() { | 2115 test_class_constructor_fieldFormal_optional_withDefault() { |
| 1488 checkLibrary('class C { int x; C([this.x = 42]); }'); | 2116 var library = checkLibrary('class C { int x; C([this.x = 42]); }'); |
| 2117 if (isStrongMode) { |
| 2118 checkElementText( |
| 2119 library, |
| 2120 r''' |
| 2121 class C { |
| 2122 int x; |
| 2123 C([int this.x]); |
| 2124 } |
| 2125 '''); |
| 2126 } else { |
| 2127 checkElementText( |
| 2128 library, |
| 2129 r''' |
| 2130 class C { |
| 2131 int x; |
| 2132 C([int this.x]); |
| 2133 } |
| 2134 '''); |
| 2135 } |
| 1489 } | 2136 } |
| 1490 | 2137 |
| 1491 test_class_constructor_implicit() { | 2138 test_class_constructor_implicit() { |
| 1492 checkLibrary('class C {}'); | 2139 var library = checkLibrary('class C {}'); |
| 2140 if (isStrongMode) { |
| 2141 checkElementText( |
| 2142 library, |
| 2143 r''' |
| 2144 class C { |
| 2145 } |
| 2146 '''); |
| 2147 } else { |
| 2148 checkElementText( |
| 2149 library, |
| 2150 r''' |
| 2151 class C { |
| 2152 } |
| 2153 '''); |
| 2154 } |
| 1493 } | 2155 } |
| 1494 | 2156 |
| 1495 test_class_constructor_implicit_type_params() { | 2157 test_class_constructor_implicit_type_params() { |
| 1496 checkLibrary('class C<T, U> {}'); | 2158 var library = checkLibrary('class C<T, U> {}'); |
| 2159 if (isStrongMode) { |
| 2160 checkElementText( |
| 2161 library, |
| 2162 r''' |
| 2163 class C<T, U> { |
| 2164 } |
| 2165 '''); |
| 2166 } else { |
| 2167 checkElementText( |
| 2168 library, |
| 2169 r''' |
| 2170 class C<T, U> { |
| 2171 } |
| 2172 '''); |
| 2173 } |
| 1497 } | 2174 } |
| 1498 | 2175 |
| 1499 test_class_constructor_params() { | 2176 test_class_constructor_params() { |
| 1500 checkLibrary('class C { C(x, y); }'); | 2177 var library = checkLibrary('class C { C(x, int y); }'); |
| 2178 if (isStrongMode) { |
| 2179 checkElementText( |
| 2180 library, |
| 2181 r''' |
| 2182 class C { |
| 2183 C(dynamic x, int y); |
| 2184 } |
| 2185 '''); |
| 2186 } else { |
| 2187 checkElementText( |
| 2188 library, |
| 2189 r''' |
| 2190 class C { |
| 2191 C(dynamic x, int y); |
| 2192 } |
| 2193 '''); |
| 2194 } |
| 1501 } | 2195 } |
| 1502 | 2196 |
| 1503 test_class_constructors() { | 2197 test_class_constructors() { |
| 1504 checkLibrary('class C { C.foo(); C.bar(); }'); | 2198 var library = checkLibrary('class C { C.foo(); C.bar(); }'); |
| 2199 if (isStrongMode) { |
| 2200 checkElementText( |
| 2201 library, |
| 2202 r''' |
| 2203 class C { |
| 2204 C.foo(); |
| 2205 C.bar(); |
| 2206 } |
| 2207 '''); |
| 2208 } else { |
| 2209 checkElementText( |
| 2210 library, |
| 2211 r''' |
| 2212 class C { |
| 2213 C.foo(); |
| 2214 C.bar(); |
| 2215 } |
| 2216 '''); |
| 2217 } |
| 1505 } | 2218 } |
| 1506 | 2219 |
| 1507 test_class_documented() { | 2220 test_class_documented() { |
| 1508 checkLibrary(''' | 2221 var library = checkLibrary(''' |
| 1509 // Extra comment so doc comment offset != 0 | 2222 // Extra comment so doc comment offset != 0 |
| 1510 /** | 2223 /** |
| 1511 * Docs | 2224 * Docs |
| 1512 */ | 2225 */ |
| 1513 class C {}'''); | 2226 class C {}'''); |
| 2227 if (isStrongMode) { |
| 2228 checkElementText( |
| 2229 library, |
| 2230 r''' |
| 2231 /** |
| 2232 * Docs |
| 2233 */ |
| 2234 class C { |
| 2235 } |
| 2236 '''); |
| 2237 } else { |
| 2238 checkElementText( |
| 2239 library, |
| 2240 r''' |
| 2241 /** |
| 2242 * Docs |
| 2243 */ |
| 2244 class C { |
| 2245 } |
| 2246 '''); |
| 2247 } |
| 1514 } | 2248 } |
| 1515 | 2249 |
| 1516 test_class_documented_tripleSlash() { | 2250 test_class_documented_tripleSlash() { |
| 1517 checkLibrary(''' | 2251 var library = checkLibrary(''' |
| 1518 /// aaa | 2252 /// aaa |
| 1519 /// bbbb | 2253 /// bbbb |
| 1520 /// cc | 2254 /// cc |
| 1521 class C {}'''); | 2255 class C {}'''); |
| 2256 if (isStrongMode) { |
| 2257 checkElementText( |
| 2258 library, |
| 2259 r''' |
| 2260 /// aaa |
| 2261 /// bbbb |
| 2262 /// cc |
| 2263 class C { |
| 2264 } |
| 2265 '''); |
| 2266 } else { |
| 2267 checkElementText( |
| 2268 library, |
| 2269 r''' |
| 2270 /// aaa |
| 2271 /// bbbb |
| 2272 /// cc |
| 2273 class C { |
| 2274 } |
| 2275 '''); |
| 2276 } |
| 1522 } | 2277 } |
| 1523 | 2278 |
| 1524 test_class_documented_with_references() { | 2279 test_class_documented_with_references() { |
| 1525 checkLibrary(''' | 2280 var library = checkLibrary(''' |
| 1526 /** | 2281 /** |
| 1527 * Docs referring to [D] and [E] | 2282 * Docs referring to [D] and [E] |
| 1528 */ | 2283 */ |
| 1529 class C {} | 2284 class C {} |
| 1530 | 2285 |
| 1531 class D {} | 2286 class D {} |
| 1532 class E {}'''); | 2287 class E {}'''); |
| 2288 if (isStrongMode) { |
| 2289 checkElementText( |
| 2290 library, |
| 2291 r''' |
| 2292 /** |
| 2293 * Docs referring to [D] and [E] |
| 2294 */ |
| 2295 class C { |
| 2296 } |
| 2297 class D { |
| 2298 } |
| 2299 class E { |
| 2300 } |
| 2301 '''); |
| 2302 } else { |
| 2303 checkElementText( |
| 2304 library, |
| 2305 r''' |
| 2306 /** |
| 2307 * Docs referring to [D] and [E] |
| 2308 */ |
| 2309 class C { |
| 2310 } |
| 2311 class D { |
| 2312 } |
| 2313 class E { |
| 2314 } |
| 2315 '''); |
| 2316 } |
| 1533 } | 2317 } |
| 1534 | 2318 |
| 1535 test_class_documented_with_windows_line_endings() { | 2319 test_class_documented_with_windows_line_endings() { |
| 1536 checkLibrary('/**\r\n * Docs\r\n */\r\nclass C {}'); | 2320 var library = checkLibrary('/**\r\n * Docs\r\n */\r\nclass C {}'); |
| 2321 if (isStrongMode) { |
| 2322 checkElementText( |
| 2323 library, |
| 2324 r''' |
| 2325 /** |
| 2326 * Docs |
| 2327 */ |
| 2328 class C { |
| 2329 } |
| 2330 '''); |
| 2331 } else { |
| 2332 checkElementText( |
| 2333 library, |
| 2334 r''' |
| 2335 /** |
| 2336 * Docs |
| 2337 */ |
| 2338 class C { |
| 2339 } |
| 2340 '''); |
| 2341 } |
| 1537 } | 2342 } |
| 1538 | 2343 |
| 1539 test_class_field_const() { | 2344 test_class_field_const() { |
| 1540 checkLibrary('class C { static const int i = 0; }'); | 2345 var library = checkLibrary('class C { static const int i = 0; }'); |
| 2346 if (isStrongMode) { |
| 2347 checkElementText( |
| 2348 library, |
| 2349 r''' |
| 2350 class C { |
| 2351 static const int i = 0; |
| 2352 } |
| 2353 '''); |
| 2354 } else { |
| 2355 checkElementText( |
| 2356 library, |
| 2357 r''' |
| 2358 class C { |
| 2359 static const int i = 0; |
| 2360 } |
| 2361 '''); |
| 2362 } |
| 1541 } | 2363 } |
| 1542 | 2364 |
| 1543 test_class_field_implicit_type() { | 2365 test_class_field_implicit_type() { |
| 1544 checkLibrary('class C { var x; }'); | 2366 var library = checkLibrary('class C { var x; }'); |
| 2367 if (isStrongMode) { |
| 2368 checkElementText( |
| 2369 library, |
| 2370 r''' |
| 2371 class C { |
| 2372 dynamic x; |
| 2373 } |
| 2374 '''); |
| 2375 } else { |
| 2376 checkElementText( |
| 2377 library, |
| 2378 r''' |
| 2379 class C { |
| 2380 dynamic x; |
| 2381 } |
| 2382 '''); |
| 2383 } |
| 1545 } | 2384 } |
| 1546 | 2385 |
| 1547 test_class_field_static() { | 2386 test_class_field_static() { |
| 1548 checkLibrary('class C { static int i; }'); | 2387 var library = checkLibrary('class C { static int i; }'); |
| 2388 if (isStrongMode) { |
| 2389 checkElementText( |
| 2390 library, |
| 2391 r''' |
| 2392 class C { |
| 2393 static int i; |
| 2394 } |
| 2395 '''); |
| 2396 } else { |
| 2397 checkElementText( |
| 2398 library, |
| 2399 r''' |
| 2400 class C { |
| 2401 static int i; |
| 2402 } |
| 2403 '''); |
| 2404 } |
| 1549 } | 2405 } |
| 1550 | 2406 |
| 1551 test_class_fields() { | 2407 test_class_fields() { |
| 1552 checkLibrary('class C { int i; int j; }'); | 2408 var library = checkLibrary('class C { int i; int j; }'); |
| 2409 if (isStrongMode) { |
| 2410 checkElementText( |
| 2411 library, |
| 2412 r''' |
| 2413 class C { |
| 2414 int i; |
| 2415 int j; |
| 2416 } |
| 2417 '''); |
| 2418 } else { |
| 2419 checkElementText( |
| 2420 library, |
| 2421 r''' |
| 2422 class C { |
| 2423 int i; |
| 2424 int j; |
| 2425 } |
| 2426 '''); |
| 2427 } |
| 1553 } | 2428 } |
| 1554 | 2429 |
| 1555 test_class_getter_abstract() { | 2430 test_class_getter_abstract() { |
| 1556 checkLibrary('abstract class C { int get x; }'); | 2431 var library = checkLibrary('abstract class C { int get x; }'); |
| 2432 if (isStrongMode) { |
| 2433 checkElementText( |
| 2434 library, |
| 2435 r''' |
| 2436 abstract class C { |
| 2437 int get x; |
| 2438 } |
| 2439 '''); |
| 2440 } else { |
| 2441 checkElementText( |
| 2442 library, |
| 2443 r''' |
| 2444 abstract class C { |
| 2445 int get x; |
| 2446 } |
| 2447 '''); |
| 2448 } |
| 1557 } | 2449 } |
| 1558 | 2450 |
| 1559 test_class_getter_external() { | 2451 test_class_getter_external() { |
| 1560 checkLibrary('class C { external int get x; }'); | 2452 var library = checkLibrary('class C { external int get x; }'); |
| 2453 if (isStrongMode) { |
| 2454 checkElementText( |
| 2455 library, |
| 2456 r''' |
| 2457 class C { |
| 2458 external int get x {} |
| 2459 } |
| 2460 '''); |
| 2461 } else { |
| 2462 checkElementText( |
| 2463 library, |
| 2464 r''' |
| 2465 class C { |
| 2466 external int get x {} |
| 2467 } |
| 2468 '''); |
| 2469 } |
| 1561 } | 2470 } |
| 1562 | 2471 |
| 1563 test_class_getter_implicit_return_type() { | 2472 test_class_getter_implicit_return_type() { |
| 1564 checkLibrary('class C { get x => null; }'); | 2473 var library = checkLibrary('class C { get x => null; }'); |
| 2474 if (isStrongMode) { |
| 2475 checkElementText( |
| 2476 library, |
| 2477 r''' |
| 2478 class C { |
| 2479 dynamic get x {} |
| 2480 } |
| 2481 '''); |
| 2482 } else { |
| 2483 checkElementText( |
| 2484 library, |
| 2485 r''' |
| 2486 class C { |
| 2487 dynamic get x {} |
| 2488 } |
| 2489 '''); |
| 2490 } |
| 1565 } | 2491 } |
| 1566 | 2492 |
| 1567 test_class_getter_static() { | 2493 test_class_getter_static() { |
| 1568 checkLibrary('class C { static int get x => null; }'); | 2494 var library = checkLibrary('class C { static int get x => null; }'); |
| 2495 if (isStrongMode) { |
| 2496 checkElementText( |
| 2497 library, |
| 2498 r''' |
| 2499 class C { |
| 2500 static int get x {} |
| 2501 } |
| 2502 '''); |
| 2503 } else { |
| 2504 checkElementText( |
| 2505 library, |
| 2506 r''' |
| 2507 class C { |
| 2508 static int get x {} |
| 2509 } |
| 2510 '''); |
| 2511 } |
| 1569 } | 2512 } |
| 1570 | 2513 |
| 1571 test_class_getters() { | 2514 test_class_getters() { |
| 1572 checkLibrary('class C { int get x => null; get y => null; }'); | 2515 var library = checkLibrary('class C { int get x => null; get y => null; }'); |
| 2516 if (isStrongMode) { |
| 2517 checkElementText( |
| 2518 library, |
| 2519 r''' |
| 2520 class C { |
| 2521 int get x {} |
| 2522 dynamic get y {} |
| 2523 } |
| 2524 '''); |
| 2525 } else { |
| 2526 checkElementText( |
| 2527 library, |
| 2528 r''' |
| 2529 class C { |
| 2530 int get x {} |
| 2531 dynamic get y {} |
| 2532 } |
| 2533 '''); |
| 2534 } |
| 1573 } | 2535 } |
| 1574 | 2536 |
| 1575 test_class_implicitField_getterFirst() { | 2537 test_class_implicitField_getterFirst() { |
| 1576 checkLibrary('class C { int get x => 0; void set x(int value) {} }'); | 2538 var library = |
| 2539 checkLibrary('class C { int get x => 0; void set x(int value) {} }'); |
| 2540 if (isStrongMode) { |
| 2541 checkElementText( |
| 2542 library, |
| 2543 r''' |
| 2544 class C { |
| 2545 int get x {} |
| 2546 void set x(int value) {} |
| 2547 } |
| 2548 '''); |
| 2549 } else { |
| 2550 checkElementText( |
| 2551 library, |
| 2552 r''' |
| 2553 class C { |
| 2554 int get x {} |
| 2555 void set x(int value) {} |
| 2556 } |
| 2557 '''); |
| 2558 } |
| 1577 } | 2559 } |
| 1578 | 2560 |
| 1579 test_class_implicitField_setterFirst() { | 2561 test_class_implicitField_setterFirst() { |
| 1580 checkLibrary('class C { void set x(int value) {} int get x => 0; }'); | 2562 var library = |
| 2563 checkLibrary('class C { void set x(int value) {} int get x => 0; }'); |
| 2564 if (isStrongMode) { |
| 2565 checkElementText( |
| 2566 library, |
| 2567 r''' |
| 2568 class C { |
| 2569 void set x(int value) {} |
| 2570 int get x {} |
| 2571 } |
| 2572 '''); |
| 2573 } else { |
| 2574 checkElementText( |
| 2575 library, |
| 2576 r''' |
| 2577 class C { |
| 2578 void set x(int value) {} |
| 2579 int get x {} |
| 2580 } |
| 2581 '''); |
| 2582 } |
| 1581 } | 2583 } |
| 1582 | 2584 |
| 1583 test_class_interfaces() { | 2585 test_class_interfaces() { |
| 1584 checkLibrary('class C implements D, E {} class D {} class E {}'); | 2586 var library = |
| 2587 checkLibrary('class C implements D, E {} class D {} class E {}'); |
| 2588 if (isStrongMode) { |
| 2589 checkElementText( |
| 2590 library, |
| 2591 r''' |
| 2592 class C implements D, E { |
| 2593 } |
| 2594 class D { |
| 2595 } |
| 2596 class E { |
| 2597 } |
| 2598 '''); |
| 2599 } else { |
| 2600 checkElementText( |
| 2601 library, |
| 2602 r''' |
| 2603 class C implements D, E { |
| 2604 } |
| 2605 class D { |
| 2606 } |
| 2607 class E { |
| 2608 } |
| 2609 '''); |
| 2610 } |
| 1585 } | 2611 } |
| 1586 | 2612 |
| 1587 test_class_interfaces_unresolved() { | 2613 test_class_interfaces_unresolved() { |
| 1588 checkLibrary('class C implements X, Y, Z {} class X {} class Z {}', | 2614 var library = checkLibrary( |
| 2615 'class C implements X, Y, Z {} class X {} class Z {}', |
| 1589 allowErrors: true); | 2616 allowErrors: true); |
| 2617 if (isStrongMode) { |
| 2618 checkElementText( |
| 2619 library, |
| 2620 r''' |
| 2621 class C implements X, Z { |
| 2622 } |
| 2623 class X { |
| 2624 } |
| 2625 class Z { |
| 2626 } |
| 2627 '''); |
| 2628 } else { |
| 2629 checkElementText( |
| 2630 library, |
| 2631 r''' |
| 2632 class C implements X, Z { |
| 2633 } |
| 2634 class X { |
| 2635 } |
| 2636 class Z { |
| 2637 } |
| 2638 '''); |
| 2639 } |
| 1590 } | 2640 } |
| 1591 | 2641 |
| 1592 test_class_method_abstract() { | 2642 test_class_method_abstract() { |
| 1593 checkLibrary('abstract class C { f(); }'); | 2643 var library = checkLibrary('abstract class C { f(); }'); |
| 2644 if (isStrongMode) { |
| 2645 checkElementText( |
| 2646 library, |
| 2647 r''' |
| 2648 abstract class C { |
| 2649 dynamic f(); |
| 2650 } |
| 2651 '''); |
| 2652 } else { |
| 2653 checkElementText( |
| 2654 library, |
| 2655 r''' |
| 2656 abstract class C { |
| 2657 dynamic f(); |
| 2658 } |
| 2659 '''); |
| 2660 } |
| 1594 } | 2661 } |
| 1595 | 2662 |
| 1596 test_class_method_external() { | 2663 test_class_method_external() { |
| 1597 checkLibrary('class C { external f(); }'); | 2664 var library = checkLibrary('class C { external f(); }'); |
| 2665 if (isStrongMode) { |
| 2666 checkElementText( |
| 2667 library, |
| 2668 r''' |
| 2669 class C { |
| 2670 external dynamic f() {} |
| 2671 } |
| 2672 '''); |
| 2673 } else { |
| 2674 checkElementText( |
| 2675 library, |
| 2676 r''' |
| 2677 class C { |
| 2678 external dynamic f() {} |
| 2679 } |
| 2680 '''); |
| 2681 } |
| 1598 } | 2682 } |
| 1599 | 2683 |
| 1600 test_class_method_params() { | 2684 test_class_method_params() { |
| 1601 checkLibrary('class C { f(x, y) {} }'); | 2685 var library = checkLibrary('class C { f(x, y) {} }'); |
| 2686 if (isStrongMode) { |
| 2687 checkElementText( |
| 2688 library, |
| 2689 r''' |
| 2690 class C { |
| 2691 dynamic f(dynamic x, dynamic y) {} |
| 2692 } |
| 2693 '''); |
| 2694 } else { |
| 2695 checkElementText( |
| 2696 library, |
| 2697 r''' |
| 2698 class C { |
| 2699 dynamic f(dynamic x, dynamic y) {} |
| 2700 } |
| 2701 '''); |
| 2702 } |
| 1602 } | 2703 } |
| 1603 | 2704 |
| 1604 test_class_method_static() { | 2705 test_class_method_static() { |
| 1605 checkLibrary('class C { static f() {} }'); | 2706 var library = checkLibrary('class C { static f() {} }'); |
| 2707 if (isStrongMode) { |
| 2708 checkElementText( |
| 2709 library, |
| 2710 r''' |
| 2711 class C { |
| 2712 static dynamic f() {} |
| 2713 } |
| 2714 '''); |
| 2715 } else { |
| 2716 checkElementText( |
| 2717 library, |
| 2718 r''' |
| 2719 class C { |
| 2720 static dynamic f() {} |
| 2721 } |
| 2722 '''); |
| 2723 } |
| 1606 } | 2724 } |
| 1607 | 2725 |
| 1608 test_class_methods() { | 2726 test_class_methods() { |
| 1609 checkLibrary('class C { f() {} g() {} }'); | 2727 var library = checkLibrary('class C { f() {} g() {} }'); |
| 2728 if (isStrongMode) { |
| 2729 checkElementText( |
| 2730 library, |
| 2731 r''' |
| 2732 class C { |
| 2733 dynamic f() {} |
| 2734 dynamic g() {} |
| 2735 } |
| 2736 '''); |
| 2737 } else { |
| 2738 checkElementText( |
| 2739 library, |
| 2740 r''' |
| 2741 class C { |
| 2742 dynamic f() {} |
| 2743 dynamic g() {} |
| 2744 } |
| 2745 '''); |
| 2746 } |
| 1610 } | 2747 } |
| 1611 | 2748 |
| 1612 test_class_mixins() { | 2749 test_class_mixins() { |
| 1613 checkLibrary('class C extends Object with D, E {} class D {} class E {}'); | 2750 var library = checkLibrary( |
| 2751 'class C extends Object with D, E {} class D {} class E {}'); |
| 2752 if (isStrongMode) { |
| 2753 checkElementText( |
| 2754 library, |
| 2755 r''' |
| 2756 class C extends Object with D, E { |
| 2757 synthetic C(); |
| 2758 } |
| 2759 class D { |
| 2760 } |
| 2761 class E { |
| 2762 } |
| 2763 '''); |
| 2764 } else { |
| 2765 checkElementText( |
| 2766 library, |
| 2767 r''' |
| 2768 class C extends Object with D, E { |
| 2769 synthetic C(); |
| 2770 } |
| 2771 class D { |
| 2772 } |
| 2773 class E { |
| 2774 } |
| 2775 '''); |
| 2776 } |
| 1614 } | 2777 } |
| 1615 | 2778 |
| 1616 test_class_mixins_unresolved() { | 2779 test_class_mixins_unresolved() { |
| 1617 checkLibrary('class C extends Object with X, Y, Z; class X {} class Z {}', | 2780 var library = checkLibrary( |
| 2781 'class C extends Object with X, Y, Z; class X {} class Z {}', |
| 1618 allowErrors: true); | 2782 allowErrors: true); |
| 2783 if (isStrongMode) { |
| 2784 checkElementText( |
| 2785 library, |
| 2786 r''' |
| 2787 class C extends Object with X, Z { |
| 2788 synthetic C(); |
| 2789 } |
| 2790 class X { |
| 2791 } |
| 2792 class Z { |
| 2793 } |
| 2794 '''); |
| 2795 } else { |
| 2796 checkElementText( |
| 2797 library, |
| 2798 r''' |
| 2799 class C extends Object with X, Z { |
| 2800 synthetic C(); |
| 2801 } |
| 2802 class X { |
| 2803 } |
| 2804 class Z { |
| 2805 } |
| 2806 '''); |
| 2807 } |
| 1619 } | 2808 } |
| 1620 | 2809 |
| 1621 test_class_setter_abstract() { | 2810 test_class_setter_abstract() { |
| 1622 checkLibrary('abstract class C { void set x(int value); }'); | 2811 var library = checkLibrary('abstract class C { void set x(int value); }'); |
| 2812 if (isStrongMode) { |
| 2813 checkElementText( |
| 2814 library, |
| 2815 r''' |
| 2816 abstract class C { |
| 2817 void set x(int value); |
| 2818 } |
| 2819 '''); |
| 2820 } else { |
| 2821 checkElementText( |
| 2822 library, |
| 2823 r''' |
| 2824 abstract class C { |
| 2825 void set x(int value); |
| 2826 } |
| 2827 '''); |
| 2828 } |
| 1623 } | 2829 } |
| 1624 | 2830 |
| 1625 test_class_setter_external() { | 2831 test_class_setter_external() { |
| 1626 checkLibrary('class C { external void set x(int value); }'); | 2832 var library = checkLibrary('class C { external void set x(int value); }'); |
| 2833 if (isStrongMode) { |
| 2834 checkElementText( |
| 2835 library, |
| 2836 r''' |
| 2837 class C { |
| 2838 external void set x(int value) {} |
| 2839 } |
| 2840 '''); |
| 2841 } else { |
| 2842 checkElementText( |
| 2843 library, |
| 2844 r''' |
| 2845 class C { |
| 2846 external void set x(int value) {} |
| 2847 } |
| 2848 '''); |
| 2849 } |
| 1627 } | 2850 } |
| 1628 | 2851 |
| 1629 test_class_setter_implicit_param_type() { | 2852 test_class_setter_implicit_param_type() { |
| 1630 checkLibrary('class C { void set x(value) {} }'); | 2853 var library = checkLibrary('class C { void set x(value) {} }'); |
| 2854 if (isStrongMode) { |
| 2855 checkElementText( |
| 2856 library, |
| 2857 r''' |
| 2858 class C { |
| 2859 void set x(dynamic value) {} |
| 2860 } |
| 2861 '''); |
| 2862 } else { |
| 2863 checkElementText( |
| 2864 library, |
| 2865 r''' |
| 2866 class C { |
| 2867 void set x(dynamic value) {} |
| 2868 } |
| 2869 '''); |
| 2870 } |
| 1631 } | 2871 } |
| 1632 | 2872 |
| 1633 test_class_setter_implicit_return_type() { | 2873 test_class_setter_implicit_return_type() { |
| 1634 checkLibrary('class C { set x(int value) {} }'); | 2874 var library = checkLibrary('class C { set x(int value) {} }'); |
| 2875 if (isStrongMode) { |
| 2876 checkElementText( |
| 2877 library, |
| 2878 r''' |
| 2879 class C { |
| 2880 void set x(int value) {} |
| 2881 } |
| 2882 '''); |
| 2883 } else { |
| 2884 checkElementText( |
| 2885 library, |
| 2886 r''' |
| 2887 class C { |
| 2888 dynamic set x(int value) {} |
| 2889 } |
| 2890 '''); |
| 2891 } |
| 1635 } | 2892 } |
| 1636 | 2893 |
| 1637 test_class_setter_invalid_no_parameter() { | 2894 test_class_setter_invalid_no_parameter() { |
| 1638 checkLibrary('class C { void set x() {} }'); | 2895 var library = checkLibrary('class C { void set x() {} }'); |
| 2896 if (isStrongMode) { |
| 2897 checkElementText( |
| 2898 library, |
| 2899 r''' |
| 2900 class C { |
| 2901 void set x() {} |
| 2902 } |
| 2903 '''); |
| 2904 } else { |
| 2905 checkElementText( |
| 2906 library, |
| 2907 r''' |
| 2908 class C { |
| 2909 void set x() {} |
| 2910 } |
| 2911 '''); |
| 2912 } |
| 1639 } | 2913 } |
| 1640 | 2914 |
| 1641 test_class_setter_static() { | 2915 test_class_setter_static() { |
| 1642 checkLibrary('class C { static void set x(int value) {} }'); | 2916 var library = checkLibrary('class C { static void set x(int value) {} }'); |
| 2917 if (isStrongMode) { |
| 2918 checkElementText( |
| 2919 library, |
| 2920 r''' |
| 2921 class C { |
| 2922 static void set x(int value) {} |
| 2923 } |
| 2924 '''); |
| 2925 } else { |
| 2926 checkElementText( |
| 2927 library, |
| 2928 r''' |
| 2929 class C { |
| 2930 static void set x(int value) {} |
| 2931 } |
| 2932 '''); |
| 2933 } |
| 1643 } | 2934 } |
| 1644 | 2935 |
| 1645 test_class_setters() { | 2936 test_class_setters() { |
| 1646 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); | 2937 var library = |
| 2938 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); |
| 2939 if (isStrongMode) { |
| 2940 checkElementText( |
| 2941 library, |
| 2942 r''' |
| 2943 class C { |
| 2944 void set x(int value) {} |
| 2945 void set y(dynamic value) {} |
| 2946 } |
| 2947 '''); |
| 2948 } else { |
| 2949 checkElementText( |
| 2950 library, |
| 2951 r''' |
| 2952 class C { |
| 2953 void set x(int value) {} |
| 2954 dynamic set y(dynamic value) {} |
| 2955 } |
| 2956 '''); |
| 2957 } |
| 1647 } | 2958 } |
| 1648 | 2959 |
| 1649 test_class_supertype() { | 2960 test_class_supertype() { |
| 1650 checkLibrary('class C extends D {} class D {}'); | 2961 var library = checkLibrary('class C extends D {} class D {}'); |
| 2962 if (isStrongMode) { |
| 2963 checkElementText( |
| 2964 library, |
| 2965 r''' |
| 2966 class C extends D { |
| 2967 } |
| 2968 class D { |
| 2969 } |
| 2970 '''); |
| 2971 } else { |
| 2972 checkElementText( |
| 2973 library, |
| 2974 r''' |
| 2975 class C extends D { |
| 2976 } |
| 2977 class D { |
| 2978 } |
| 2979 '''); |
| 2980 } |
| 1651 } | 2981 } |
| 1652 | 2982 |
| 1653 test_class_supertype_unresolved() { | 2983 test_class_supertype_unresolved() { |
| 1654 checkLibrary('class C extends D {}', allowErrors: true); | 2984 var library = checkLibrary('class C extends D {}', allowErrors: true); |
| 2985 if (isStrongMode) { |
| 2986 checkElementText( |
| 2987 library, |
| 2988 r''' |
| 2989 class C { |
| 2990 } |
| 2991 '''); |
| 2992 } else { |
| 2993 checkElementText( |
| 2994 library, |
| 2995 r''' |
| 2996 class C { |
| 2997 } |
| 2998 '''); |
| 2999 } |
| 1655 } | 3000 } |
| 1656 | 3001 |
| 1657 test_class_type_parameters() { | 3002 test_class_type_parameters() { |
| 1658 checkLibrary('class C<T, U> {}'); | 3003 var library = checkLibrary('class C<T, U> {}'); |
| 3004 if (isStrongMode) { |
| 3005 checkElementText( |
| 3006 library, |
| 3007 r''' |
| 3008 class C<T, U> { |
| 3009 } |
| 3010 '''); |
| 3011 } else { |
| 3012 checkElementText( |
| 3013 library, |
| 3014 r''' |
| 3015 class C<T, U> { |
| 3016 } |
| 3017 '''); |
| 3018 } |
| 1659 } | 3019 } |
| 1660 | 3020 |
| 1661 test_class_type_parameters_bound() { | 3021 test_class_type_parameters_bound() { |
| 1662 checkLibrary('class C<T extends Object, U extends D> {} class D {}'); | 3022 var library = |
| 3023 checkLibrary('class C<T extends Object, U extends D> {} class D {}'); |
| 3024 if (isStrongMode) { |
| 3025 checkElementText( |
| 3026 library, |
| 3027 r''' |
| 3028 class C<T extends Object, U extends D> { |
| 3029 } |
| 3030 class D { |
| 3031 } |
| 3032 '''); |
| 3033 } else { |
| 3034 checkElementText( |
| 3035 library, |
| 3036 r''' |
| 3037 class C<T extends Object, U extends D> { |
| 3038 } |
| 3039 class D { |
| 3040 } |
| 3041 '''); |
| 3042 } |
| 1663 } | 3043 } |
| 1664 | 3044 |
| 1665 test_class_type_parameters_f_bound_complex() { | 3045 test_class_type_parameters_f_bound_complex() { |
| 1666 checkLibrary('class C<T extends List<U>, U> {}'); | 3046 var library = checkLibrary('class C<T extends List<U>, U> {}'); |
| 3047 if (isStrongMode) { |
| 3048 checkElementText( |
| 3049 library, |
| 3050 r''' |
| 3051 class C<T extends List<U>, U> { |
| 3052 } |
| 3053 '''); |
| 3054 } else { |
| 3055 checkElementText( |
| 3056 library, |
| 3057 r''' |
| 3058 class C<T extends List<U>, U> { |
| 3059 } |
| 3060 '''); |
| 3061 } |
| 1667 } | 3062 } |
| 1668 | 3063 |
| 1669 test_class_type_parameters_f_bound_simple() { | 3064 test_class_type_parameters_f_bound_simple() { |
| 1670 checkLibrary('class C<T extends U, U> {}'); | 3065 var library = checkLibrary('class C<T extends U, U> {}'); |
| 3066 if (isStrongMode) { |
| 3067 checkElementText( |
| 3068 library, |
| 3069 r''' |
| 3070 class C<T extends U, U> { |
| 3071 } |
| 3072 '''); |
| 3073 } else { |
| 3074 checkElementText( |
| 3075 library, |
| 3076 r''' |
| 3077 class C<T extends U, U> { |
| 3078 } |
| 3079 '''); |
| 3080 } |
| 1671 } | 3081 } |
| 1672 | 3082 |
| 1673 test_classes() { | 3083 test_classes() { |
| 1674 checkLibrary('class C {} class D {}'); | 3084 var library = checkLibrary('class C {} class D {}'); |
| 3085 if (isStrongMode) { |
| 3086 checkElementText( |
| 3087 library, |
| 3088 r''' |
| 3089 class C { |
| 3090 } |
| 3091 class D { |
| 3092 } |
| 3093 '''); |
| 3094 } else { |
| 3095 checkElementText( |
| 3096 library, |
| 3097 r''' |
| 3098 class C { |
| 3099 } |
| 3100 class D { |
| 3101 } |
| 3102 '''); |
| 3103 } |
| 1675 } | 3104 } |
| 1676 | 3105 |
| 1677 test_closure_executable_with_return_type_from_closure() { | 3106 test_closure_executable_with_return_type_from_closure() { |
| 1678 checkLibrary(''' | 3107 var library = checkLibrary(''' |
| 1679 f() { | 3108 f() { |
| 1680 print(() {}); | 3109 print(() {}); |
| 1681 print(() => () => 0); | 3110 print(() => () => 0); |
| 1682 } | 3111 } |
| 1683 '''); | 3112 '''); |
| 3113 if (isStrongMode) { |
| 3114 checkElementText( |
| 3115 library, |
| 3116 r''' |
| 3117 dynamic f() {} |
| 3118 '''); |
| 3119 } else { |
| 3120 checkElementText( |
| 3121 library, |
| 3122 r''' |
| 3123 dynamic f() {} |
| 3124 '''); |
| 3125 } |
| 1684 } | 3126 } |
| 1685 | 3127 |
| 1686 test_closure_generic() { | 3128 test_closure_generic() { |
| 1687 checkLibrary('final f = <U, V>(U x, V y) => y;'); | 3129 var library = checkLibrary('final f = <U, V>(U x, V y) => y;'); |
| 3130 if (isStrongMode) { |
| 3131 checkElementText( |
| 3132 library, |
| 3133 r''' |
| 3134 final <U,V>(U, V) → V f; |
| 3135 '''); |
| 3136 } else { |
| 3137 checkElementText( |
| 3138 library, |
| 3139 r''' |
| 3140 final dynamic f; |
| 3141 '''); |
| 3142 } |
| 1688 } | 3143 } |
| 1689 | 3144 |
| 1690 test_closure_in_variable_declaration_in_part() { | 3145 test_closure_in_variable_declaration_in_part() { |
| 1691 addSource('/a.dart', 'part of lib; final f = (int i) => i.toDouble();'); | 3146 addSource('/a.dart', 'part of lib; final f = (int i) => i.toDouble();'); |
| 1692 checkLibrary(''' | 3147 var library = checkLibrary(''' |
| 1693 library lib; | 3148 library lib; |
| 1694 part "a.dart"; | 3149 part "a.dart"; |
| 1695 '''); | 3150 '''); |
| 3151 if (isStrongMode) { |
| 3152 checkElementText( |
| 3153 library, |
| 3154 r''' |
| 3155 library lib; |
| 3156 part 'a.dart'; |
| 3157 -------------------- |
| 3158 unit: a.dart |
| 3159 |
| 3160 final (int) → double f; |
| 3161 '''); |
| 3162 } else { |
| 3163 checkElementText( |
| 3164 library, |
| 3165 r''' |
| 3166 library lib; |
| 3167 part 'a.dart'; |
| 3168 -------------------- |
| 3169 unit: a.dart |
| 3170 |
| 3171 final dynamic f; |
| 3172 '''); |
| 3173 } |
| 1696 } | 3174 } |
| 1697 | 3175 |
| 1698 test_const_invalid_field_const() { | 3176 test_const_invalid_field_const() { |
| 1699 variablesWithNotConstInitializers.add('f'); | 3177 variablesWithNotConstInitializers.add('f'); |
| 1700 checkLibrary( | 3178 var library = checkLibrary( |
| 1701 r''' | 3179 r''' |
| 1702 class C { | 3180 class C { |
| 1703 static const f = 1 + foo(); | 3181 static const f = 1 + foo(); |
| 1704 } | 3182 } |
| 1705 int foo() => 42; | 3183 int foo() => 42; |
| 1706 ''', | 3184 ''', |
| 1707 allowErrors: true); | 3185 allowErrors: true); |
| 3186 if (isStrongMode) { |
| 3187 checkElementText( |
| 3188 library, |
| 3189 r''' |
| 3190 class C { |
| 3191 static const int f = $$invalidConstExpr$$; |
| 3192 } |
| 3193 int foo() {} |
| 3194 '''); |
| 3195 } else { |
| 3196 checkElementText( |
| 3197 library, |
| 3198 r''' |
| 3199 class C { |
| 3200 static const dynamic f = $$invalidConstExpr$$; |
| 3201 } |
| 3202 int foo() {} |
| 3203 '''); |
| 3204 } |
| 1708 } | 3205 } |
| 1709 | 3206 |
| 1710 test_const_invalid_field_final() { | 3207 test_const_invalid_field_final() { |
| 1711 variablesWithNotConstInitializers.add('f'); | 3208 variablesWithNotConstInitializers.add('f'); |
| 1712 checkLibrary( | 3209 var library = checkLibrary( |
| 1713 r''' | 3210 r''' |
| 1714 class C { | 3211 class C { |
| 1715 final f = 1 + foo(); | 3212 final f = 1 + foo(); |
| 1716 } | 3213 } |
| 1717 int foo() => 42; | 3214 int foo() => 42; |
| 1718 ''', | 3215 ''', |
| 1719 allowErrors: true); | 3216 allowErrors: true); |
| 3217 if (isStrongMode) { |
| 3218 checkElementText( |
| 3219 library, |
| 3220 r''' |
| 3221 class C { |
| 3222 final int f = $$invalidConstExpr$$; |
| 3223 } |
| 3224 int foo() {} |
| 3225 '''); |
| 3226 } else { |
| 3227 checkElementText( |
| 3228 library, |
| 3229 r''' |
| 3230 class C { |
| 3231 final dynamic f = $$invalidConstExpr$$; |
| 3232 } |
| 3233 int foo() {} |
| 3234 '''); |
| 3235 } |
| 1720 } | 3236 } |
| 1721 | 3237 |
| 1722 test_const_invalid_topLevel() { | 3238 test_const_invalid_topLevel() { |
| 1723 variablesWithNotConstInitializers.add('v'); | 3239 variablesWithNotConstInitializers.add('v'); |
| 1724 checkLibrary( | 3240 var library = checkLibrary( |
| 1725 r''' | 3241 r''' |
| 1726 const v = 1 + foo(); | 3242 const v = 1 + foo(); |
| 1727 int foo() => 42; | 3243 int foo() => 42; |
| 1728 ''', | 3244 ''', |
| 1729 allowErrors: true); | 3245 allowErrors: true); |
| 3246 if (isStrongMode) { |
| 3247 checkElementText( |
| 3248 library, |
| 3249 r''' |
| 3250 const int v = $$invalidConstExpr$$; |
| 3251 int foo() {} |
| 3252 '''); |
| 3253 } else { |
| 3254 checkElementText( |
| 3255 library, |
| 3256 r''' |
| 3257 const dynamic v = $$invalidConstExpr$$; |
| 3258 int foo() {} |
| 3259 '''); |
| 3260 } |
| 1730 } | 3261 } |
| 1731 | 3262 |
| 1732 test_const_invokeConstructor_generic_named() { | 3263 test_const_invokeConstructor_generic_named() { |
| 1733 checkLibrary(r''' | 3264 var library = checkLibrary(r''' |
| 1734 class C<K, V> { | 3265 class C<K, V> { |
| 1735 const C.named(K k, V v); | 3266 const C.named(K k, V v); |
| 1736 } | 3267 } |
| 1737 const V = const C<int, String>.named(1, '222'); | 3268 const V = const C<int, String>.named(1, '222'); |
| 1738 '''); | 3269 '''); |
| 3270 if (isStrongMode) { |
| 3271 checkElementText( |
| 3272 library, |
| 3273 r''' |
| 3274 class C<K, V> { |
| 3275 const C.named(K k, V v); |
| 3276 } |
| 3277 const C<int, String> V = const C<int, String>.named(1, '222'); |
| 3278 '''); |
| 3279 } else { |
| 3280 checkElementText( |
| 3281 library, |
| 3282 r''' |
| 3283 class C<K, V> { |
| 3284 const C.named(K k, V v); |
| 3285 } |
| 3286 const dynamic V = const C<int, String>.named(1, '222'); |
| 3287 '''); |
| 3288 } |
| 1739 } | 3289 } |
| 1740 | 3290 |
| 1741 test_const_invokeConstructor_generic_named_imported() { | 3291 test_const_invokeConstructor_generic_named_imported() { |
| 1742 addLibrarySource( | 3292 addLibrarySource( |
| 1743 '/a.dart', | 3293 '/a.dart', |
| 1744 r''' | 3294 r''' |
| 1745 class C<K, V> { | 3295 class C<K, V> { |
| 1746 const C.named(K k, V v); | 3296 const C.named(K k, V v); |
| 1747 } | 3297 } |
| 1748 '''); | 3298 '''); |
| 1749 checkLibrary(r''' | 3299 var library = checkLibrary(r''' |
| 1750 import 'a.dart'; | 3300 import 'a.dart'; |
| 1751 const V = const C<int, String>.named(1, '222'); | 3301 const V = const C<int, String>.named(1, '222'); |
| 1752 '''); | 3302 '''); |
| 3303 if (isStrongMode) { |
| 3304 checkElementText( |
| 3305 library, |
| 3306 r''' |
| 3307 import 'a.dart'; |
| 3308 const C<int, String> V = const C<int, String>.named(1, '222'); |
| 3309 '''); |
| 3310 } else { |
| 3311 checkElementText( |
| 3312 library, |
| 3313 r''' |
| 3314 import 'a.dart'; |
| 3315 const dynamic V = const C<int, String>.named(1, '222'); |
| 3316 '''); |
| 3317 } |
| 1753 } | 3318 } |
| 1754 | 3319 |
| 1755 test_const_invokeConstructor_generic_named_imported_withPrefix() { | 3320 test_const_invokeConstructor_generic_named_imported_withPrefix() { |
| 1756 addLibrarySource( | 3321 addLibrarySource( |
| 1757 '/a.dart', | 3322 '/a.dart', |
| 1758 r''' | 3323 r''' |
| 1759 class C<K, V> { | 3324 class C<K, V> { |
| 1760 const C.named(K k, V v); | 3325 const C.named(K k, V v); |
| 1761 } | 3326 } |
| 1762 '''); | 3327 '''); |
| 1763 checkLibrary(r''' | 3328 var library = checkLibrary(r''' |
| 1764 import 'a.dart' as p; | 3329 import 'a.dart' as p; |
| 1765 const V = const p.C<int, String>.named(1, '222'); | 3330 const V = const p.C<int, String>.named(1, '222'); |
| 1766 '''); | 3331 '''); |
| 3332 if (isStrongMode) { |
| 3333 checkElementText( |
| 3334 library, |
| 3335 r''' |
| 3336 import 'a.dart' as p; |
| 3337 const C<int, String> V = const C<int, String>.named(1, '222'); |
| 3338 '''); |
| 3339 } else { |
| 3340 checkElementText( |
| 3341 library, |
| 3342 r''' |
| 3343 import 'a.dart' as p; |
| 3344 const dynamic V = const C<int, String>.named(1, '222'); |
| 3345 '''); |
| 3346 } |
| 1767 } | 3347 } |
| 1768 | 3348 |
| 1769 test_const_invokeConstructor_generic_noTypeArguments() { | 3349 test_const_invokeConstructor_generic_noTypeArguments() { |
| 1770 checkLibrary(r''' | 3350 var library = checkLibrary(r''' |
| 1771 class C<K, V> { | 3351 class C<K, V> { |
| 1772 const C(); | 3352 const C(); |
| 1773 } | 3353 } |
| 1774 const V = const C(); | 3354 const V = const C(); |
| 1775 '''); | 3355 '''); |
| 3356 if (isStrongMode) { |
| 3357 checkElementText( |
| 3358 library, |
| 3359 r''' |
| 3360 class C<K, V> { |
| 3361 const C(); |
| 3362 } |
| 3363 const C<dynamic, dynamic> V = const C(); |
| 3364 '''); |
| 3365 } else { |
| 3366 checkElementText( |
| 3367 library, |
| 3368 r''' |
| 3369 class C<K, V> { |
| 3370 const C(); |
| 3371 } |
| 3372 const dynamic V = const C(); |
| 3373 '''); |
| 3374 } |
| 1776 } | 3375 } |
| 1777 | 3376 |
| 1778 test_const_invokeConstructor_generic_unnamed() { | 3377 test_const_invokeConstructor_generic_unnamed() { |
| 1779 checkLibrary(r''' | 3378 var library = checkLibrary(r''' |
| 1780 class C<K, V> { | 3379 class C<K, V> { |
| 1781 const C(); | 3380 const C(); |
| 1782 } | 3381 } |
| 1783 const V = const C<int, String>(); | 3382 const V = const C<int, String>(); |
| 1784 '''); | 3383 '''); |
| 3384 if (isStrongMode) { |
| 3385 checkElementText( |
| 3386 library, |
| 3387 r''' |
| 3388 class C<K, V> { |
| 3389 const C(); |
| 3390 } |
| 3391 const C<int, String> V = const C<int, String>(); |
| 3392 '''); |
| 3393 } else { |
| 3394 checkElementText( |
| 3395 library, |
| 3396 r''' |
| 3397 class C<K, V> { |
| 3398 const C(); |
| 3399 } |
| 3400 const dynamic V = const C<int, String>(); |
| 3401 '''); |
| 3402 } |
| 1785 } | 3403 } |
| 1786 | 3404 |
| 1787 test_const_invokeConstructor_generic_unnamed_imported() { | 3405 test_const_invokeConstructor_generic_unnamed_imported() { |
| 1788 addLibrarySource( | 3406 addLibrarySource( |
| 1789 '/a.dart', | 3407 '/a.dart', |
| 1790 r''' | 3408 r''' |
| 1791 class C<K, V> { | 3409 class C<K, V> { |
| 1792 const C(); | 3410 const C(); |
| 1793 } | 3411 } |
| 1794 '''); | 3412 '''); |
| 1795 checkLibrary(r''' | 3413 var library = checkLibrary(r''' |
| 1796 import 'a.dart'; | 3414 import 'a.dart'; |
| 1797 const V = const C<int, String>(); | 3415 const V = const C<int, String>(); |
| 1798 '''); | 3416 '''); |
| 3417 if (isStrongMode) { |
| 3418 checkElementText( |
| 3419 library, |
| 3420 r''' |
| 3421 import 'a.dart'; |
| 3422 const C<int, String> V = const C<int, String>(); |
| 3423 '''); |
| 3424 } else { |
| 3425 checkElementText( |
| 3426 library, |
| 3427 r''' |
| 3428 import 'a.dart'; |
| 3429 const dynamic V = const C<int, String>(); |
| 3430 '''); |
| 3431 } |
| 1799 } | 3432 } |
| 1800 | 3433 |
| 1801 test_const_invokeConstructor_generic_unnamed_imported_withPrefix() { | 3434 test_const_invokeConstructor_generic_unnamed_imported_withPrefix() { |
| 1802 addLibrarySource( | 3435 addLibrarySource( |
| 1803 '/a.dart', | 3436 '/a.dart', |
| 1804 r''' | 3437 r''' |
| 1805 class C<K, V> { | 3438 class C<K, V> { |
| 1806 const C(); | 3439 const C(); |
| 1807 } | 3440 } |
| 1808 '''); | 3441 '''); |
| 1809 checkLibrary(r''' | 3442 var library = checkLibrary(r''' |
| 1810 import 'a.dart' as p; | 3443 import 'a.dart' as p; |
| 1811 const V = const p.C<int, String>(); | 3444 const V = const p.C<int, String>(); |
| 1812 '''); | 3445 '''); |
| 3446 if (isStrongMode) { |
| 3447 checkElementText( |
| 3448 library, |
| 3449 r''' |
| 3450 import 'a.dart' as p; |
| 3451 const C<int, String> V = const C<int, String>(); |
| 3452 '''); |
| 3453 } else { |
| 3454 checkElementText( |
| 3455 library, |
| 3456 r''' |
| 3457 import 'a.dart' as p; |
| 3458 const dynamic V = const C<int, String>(); |
| 3459 '''); |
| 3460 } |
| 1813 } | 3461 } |
| 1814 | 3462 |
| 1815 test_const_invokeConstructor_named() { | 3463 test_const_invokeConstructor_named() { |
| 1816 checkLibrary(r''' | 3464 var library = checkLibrary(r''' |
| 1817 class C { | 3465 class C { |
| 1818 const C.named(bool a, int b, int c, {String d, double e}); | 3466 const C.named(bool a, int b, int c, {String d, double e}); |
| 1819 } | 3467 } |
| 1820 const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); | 3468 const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); |
| 1821 '''); | 3469 '''); |
| 3470 if (isStrongMode) { |
| 3471 checkElementText( |
| 3472 library, |
| 3473 r''' |
| 3474 class C { |
| 3475 const C.named(bool a, int b, int c, {String d}, {double e}); |
| 3476 } |
| 3477 const C V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); |
| 3478 '''); |
| 3479 } else { |
| 3480 checkElementText( |
| 3481 library, |
| 3482 r''' |
| 3483 class C { |
| 3484 const C.named(bool a, int b, int c, {String d}, {double e}); |
| 3485 } |
| 3486 const dynamic V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); |
| 3487 '''); |
| 3488 } |
| 1822 } | 3489 } |
| 1823 | 3490 |
| 1824 test_const_invokeConstructor_named_imported() { | 3491 test_const_invokeConstructor_named_imported() { |
| 1825 addLibrarySource( | 3492 addLibrarySource( |
| 1826 '/a.dart', | 3493 '/a.dart', |
| 1827 r''' | 3494 r''' |
| 1828 class C { | 3495 class C { |
| 1829 const C.named(); | 3496 const C.named(); |
| 1830 } | 3497 } |
| 1831 '''); | 3498 '''); |
| 1832 checkLibrary(r''' | 3499 var library = checkLibrary(r''' |
| 1833 import 'a.dart'; | 3500 import 'a.dart'; |
| 1834 const V = const C.named(); | 3501 const V = const C.named(); |
| 1835 '''); | 3502 '''); |
| 3503 if (isStrongMode) { |
| 3504 checkElementText( |
| 3505 library, |
| 3506 r''' |
| 3507 import 'a.dart'; |
| 3508 const C V = const C.named(); |
| 3509 '''); |
| 3510 } else { |
| 3511 checkElementText( |
| 3512 library, |
| 3513 r''' |
| 3514 import 'a.dart'; |
| 3515 const dynamic V = const C.named(); |
| 3516 '''); |
| 3517 } |
| 1836 } | 3518 } |
| 1837 | 3519 |
| 1838 test_const_invokeConstructor_named_imported_withPrefix() { | 3520 test_const_invokeConstructor_named_imported_withPrefix() { |
| 1839 addLibrarySource( | 3521 addLibrarySource( |
| 1840 '/a.dart', | 3522 '/a.dart', |
| 1841 r''' | 3523 r''' |
| 1842 class C { | 3524 class C { |
| 1843 const C.named(); | 3525 const C.named(); |
| 1844 } | 3526 } |
| 1845 '''); | 3527 '''); |
| 1846 checkLibrary(r''' | 3528 var library = checkLibrary(r''' |
| 1847 import 'a.dart' as p; | 3529 import 'a.dart' as p; |
| 1848 const V = const p.C.named(); | 3530 const V = const p.C.named(); |
| 1849 '''); | 3531 '''); |
| 3532 if (isStrongMode) { |
| 3533 checkElementText( |
| 3534 library, |
| 3535 r''' |
| 3536 import 'a.dart' as p; |
| 3537 const C V = const C.named(); |
| 3538 '''); |
| 3539 } else { |
| 3540 checkElementText( |
| 3541 library, |
| 3542 r''' |
| 3543 import 'a.dart' as p; |
| 3544 const dynamic V = const C.named(); |
| 3545 '''); |
| 3546 } |
| 1850 } | 3547 } |
| 1851 | 3548 |
| 1852 test_const_invokeConstructor_named_unresolved() { | 3549 test_const_invokeConstructor_named_unresolved() { |
| 1853 checkLibrary( | 3550 var library = checkLibrary( |
| 1854 r''' | 3551 r''' |
| 1855 class C {} | 3552 class C {} |
| 1856 const V = const C.named(); | 3553 const V = const C.named(); |
| 1857 ''', | 3554 ''', |
| 1858 allowErrors: true); | 3555 allowErrors: true); |
| 3556 if (isStrongMode) { |
| 3557 checkElementText( |
| 3558 library, |
| 3559 r''' |
| 3560 class C { |
| 3561 } |
| 3562 const C V = const C.named(); |
| 3563 '''); |
| 3564 } else { |
| 3565 checkElementText( |
| 3566 library, |
| 3567 r''' |
| 3568 class C { |
| 3569 } |
| 3570 const dynamic V = const C.named(); |
| 3571 '''); |
| 3572 } |
| 1859 } | 3573 } |
| 1860 | 3574 |
| 1861 test_const_invokeConstructor_named_unresolved2() { | 3575 test_const_invokeConstructor_named_unresolved2() { |
| 1862 checkLibrary( | 3576 var library = checkLibrary( |
| 1863 r''' | 3577 r''' |
| 1864 const V = const C.named(); | 3578 const V = const C.named(); |
| 1865 ''', | 3579 ''', |
| 1866 allowErrors: true); | 3580 allowErrors: true); |
| 3581 if (isStrongMode) { |
| 3582 checkElementText( |
| 3583 library, |
| 3584 r''' |
| 3585 const dynamic V = const C.named(); |
| 3586 '''); |
| 3587 } else { |
| 3588 checkElementText( |
| 3589 library, |
| 3590 r''' |
| 3591 const dynamic V = const C.named(); |
| 3592 '''); |
| 3593 } |
| 1867 } | 3594 } |
| 1868 | 3595 |
| 1869 test_const_invokeConstructor_named_unresolved3() { | 3596 test_const_invokeConstructor_named_unresolved3() { |
| 1870 addLibrarySource( | 3597 addLibrarySource( |
| 1871 '/a.dart', | 3598 '/a.dart', |
| 1872 r''' | 3599 r''' |
| 1873 class C { | 3600 class C { |
| 1874 } | 3601 } |
| 1875 '''); | 3602 '''); |
| 1876 checkLibrary( | 3603 var library = checkLibrary( |
| 1877 r''' | 3604 r''' |
| 1878 import 'a.dart' as p; | 3605 import 'a.dart' as p; |
| 1879 const V = const p.C.named(); | 3606 const V = const p.C.named(); |
| 1880 ''', | 3607 ''', |
| 1881 allowErrors: true); | 3608 allowErrors: true); |
| 3609 if (isStrongMode) { |
| 3610 checkElementText( |
| 3611 library, |
| 3612 r''' |
| 3613 import 'a.dart' as p; |
| 3614 const C V = const p.C.named(); |
| 3615 '''); |
| 3616 } else { |
| 3617 checkElementText( |
| 3618 library, |
| 3619 r''' |
| 3620 import 'a.dart' as p; |
| 3621 const dynamic V = const p.C.named(); |
| 3622 '''); |
| 3623 } |
| 1882 } | 3624 } |
| 1883 | 3625 |
| 1884 test_const_invokeConstructor_named_unresolved4() { | 3626 test_const_invokeConstructor_named_unresolved4() { |
| 1885 addLibrarySource('/a.dart', ''); | 3627 addLibrarySource('/a.dart', ''); |
| 1886 checkLibrary( | 3628 var library = checkLibrary( |
| 1887 r''' | 3629 r''' |
| 1888 import 'a.dart' as p; | 3630 import 'a.dart' as p; |
| 1889 const V = const p.C.named(); | 3631 const V = const p.C.named(); |
| 1890 ''', | 3632 ''', |
| 1891 allowErrors: true); | 3633 allowErrors: true); |
| 3634 if (isStrongMode) { |
| 3635 checkElementText( |
| 3636 library, |
| 3637 r''' |
| 3638 import 'a.dart' as p; |
| 3639 const dynamic V = const p.C.named(); |
| 3640 '''); |
| 3641 } else { |
| 3642 checkElementText( |
| 3643 library, |
| 3644 r''' |
| 3645 import 'a.dart' as p; |
| 3646 const dynamic V = const p.C.named(); |
| 3647 '''); |
| 3648 } |
| 1892 } | 3649 } |
| 1893 | 3650 |
| 1894 test_const_invokeConstructor_named_unresolved5() { | 3651 test_const_invokeConstructor_named_unresolved5() { |
| 1895 checkLibrary( | 3652 var library = checkLibrary( |
| 1896 r''' | 3653 r''' |
| 1897 const V = const p.C.named(); | 3654 const V = const p.C.named(); |
| 1898 ''', | 3655 ''', |
| 1899 allowErrors: true); | 3656 allowErrors: true); |
| 3657 if (isStrongMode) { |
| 3658 checkElementText( |
| 3659 library, |
| 3660 r''' |
| 3661 const dynamic V = const p.C.named(); |
| 3662 '''); |
| 3663 } else { |
| 3664 checkElementText( |
| 3665 library, |
| 3666 r''' |
| 3667 const dynamic V = const p.C.named(); |
| 3668 '''); |
| 3669 } |
| 1900 } | 3670 } |
| 1901 | 3671 |
| 1902 test_const_invokeConstructor_unnamed() { | 3672 test_const_invokeConstructor_unnamed() { |
| 1903 checkLibrary(r''' | 3673 var library = checkLibrary(r''' |
| 1904 class C { | 3674 class C { |
| 1905 const C(); | 3675 const C(); |
| 1906 } | 3676 } |
| 1907 const V = const C(); | 3677 const V = const C(); |
| 1908 '''); | 3678 '''); |
| 3679 if (isStrongMode) { |
| 3680 checkElementText( |
| 3681 library, |
| 3682 r''' |
| 3683 class C { |
| 3684 const C(); |
| 3685 } |
| 3686 const C V = const C(); |
| 3687 '''); |
| 3688 } else { |
| 3689 checkElementText( |
| 3690 library, |
| 3691 r''' |
| 3692 class C { |
| 3693 const C(); |
| 3694 } |
| 3695 const dynamic V = const C(); |
| 3696 '''); |
| 3697 } |
| 1909 } | 3698 } |
| 1910 | 3699 |
| 1911 test_const_invokeConstructor_unnamed_imported() { | 3700 test_const_invokeConstructor_unnamed_imported() { |
| 1912 addLibrarySource( | 3701 addLibrarySource( |
| 1913 '/a.dart', | 3702 '/a.dart', |
| 1914 r''' | 3703 r''' |
| 1915 class C { | 3704 class C { |
| 1916 const C(); | 3705 const C(); |
| 1917 } | 3706 } |
| 1918 '''); | 3707 '''); |
| 1919 checkLibrary(r''' | 3708 var library = checkLibrary(r''' |
| 1920 import 'a.dart'; | 3709 import 'a.dart'; |
| 1921 const V = const C(); | 3710 const V = const C(); |
| 1922 '''); | 3711 '''); |
| 3712 if (isStrongMode) { |
| 3713 checkElementText( |
| 3714 library, |
| 3715 r''' |
| 3716 import 'a.dart'; |
| 3717 const C V = const C(); |
| 3718 '''); |
| 3719 } else { |
| 3720 checkElementText( |
| 3721 library, |
| 3722 r''' |
| 3723 import 'a.dart'; |
| 3724 const dynamic V = const C(); |
| 3725 '''); |
| 3726 } |
| 1923 } | 3727 } |
| 1924 | 3728 |
| 1925 test_const_invokeConstructor_unnamed_imported_withPrefix() { | 3729 test_const_invokeConstructor_unnamed_imported_withPrefix() { |
| 1926 addLibrarySource( | 3730 addLibrarySource( |
| 1927 '/a.dart', | 3731 '/a.dart', |
| 1928 r''' | 3732 r''' |
| 1929 class C { | 3733 class C { |
| 1930 const C(); | 3734 const C(); |
| 1931 } | 3735 } |
| 1932 '''); | 3736 '''); |
| 1933 checkLibrary(r''' | 3737 var library = checkLibrary(r''' |
| 1934 import 'a.dart' as p; | 3738 import 'a.dart' as p; |
| 1935 const V = const p.C(); | 3739 const V = const p.C(); |
| 1936 '''); | 3740 '''); |
| 3741 if (isStrongMode) { |
| 3742 checkElementText( |
| 3743 library, |
| 3744 r''' |
| 3745 import 'a.dart' as p; |
| 3746 const C V = const C(); |
| 3747 '''); |
| 3748 } else { |
| 3749 checkElementText( |
| 3750 library, |
| 3751 r''' |
| 3752 import 'a.dart' as p; |
| 3753 const dynamic V = const C(); |
| 3754 '''); |
| 3755 } |
| 1937 } | 3756 } |
| 1938 | 3757 |
| 1939 test_const_invokeConstructor_unnamed_unresolved() { | 3758 test_const_invokeConstructor_unnamed_unresolved() { |
| 1940 checkLibrary( | 3759 var library = checkLibrary( |
| 1941 r''' | 3760 r''' |
| 1942 const V = const C(); | 3761 const V = const C(); |
| 1943 ''', | 3762 ''', |
| 1944 allowErrors: true); | 3763 allowErrors: true); |
| 3764 if (isStrongMode) { |
| 3765 checkElementText( |
| 3766 library, |
| 3767 r''' |
| 3768 const dynamic V = const C(); |
| 3769 '''); |
| 3770 } else { |
| 3771 checkElementText( |
| 3772 library, |
| 3773 r''' |
| 3774 const dynamic V = const C(); |
| 3775 '''); |
| 3776 } |
| 1945 } | 3777 } |
| 1946 | 3778 |
| 1947 test_const_invokeConstructor_unnamed_unresolved2() { | 3779 test_const_invokeConstructor_unnamed_unresolved2() { |
| 1948 addLibrarySource('/a.dart', ''); | 3780 addLibrarySource('/a.dart', ''); |
| 1949 checkLibrary( | 3781 var library = checkLibrary( |
| 1950 r''' | 3782 r''' |
| 1951 import 'a.dart' as p; | 3783 import 'a.dart' as p; |
| 1952 const V = const p.C(); | 3784 const V = const p.C(); |
| 1953 ''', | 3785 ''', |
| 1954 allowErrors: true); | 3786 allowErrors: true); |
| 3787 if (isStrongMode) { |
| 3788 checkElementText( |
| 3789 library, |
| 3790 r''' |
| 3791 import 'a.dart' as p; |
| 3792 const dynamic V = const p.C(); |
| 3793 '''); |
| 3794 } else { |
| 3795 checkElementText( |
| 3796 library, |
| 3797 r''' |
| 3798 import 'a.dart' as p; |
| 3799 const dynamic V = const p.C(); |
| 3800 '''); |
| 3801 } |
| 1955 } | 3802 } |
| 1956 | 3803 |
| 1957 test_const_invokeConstructor_unnamed_unresolved3() { | 3804 test_const_invokeConstructor_unnamed_unresolved3() { |
| 1958 checkLibrary( | 3805 var library = checkLibrary( |
| 1959 r''' | 3806 r''' |
| 1960 const V = const p.C(); | 3807 const V = const p.C(); |
| 1961 ''', | 3808 ''', |
| 1962 allowErrors: true); | 3809 allowErrors: true); |
| 3810 if (isStrongMode) { |
| 3811 checkElementText( |
| 3812 library, |
| 3813 r''' |
| 3814 const dynamic V = const p.C(); |
| 3815 '''); |
| 3816 } else { |
| 3817 checkElementText( |
| 3818 library, |
| 3819 r''' |
| 3820 const dynamic V = const p.C(); |
| 3821 '''); |
| 3822 } |
| 1963 } | 3823 } |
| 1964 | 3824 |
| 1965 test_const_length_ofClassConstField() { | 3825 test_const_length_ofClassConstField() { |
| 1966 checkLibrary(r''' | 3826 var library = checkLibrary(r''' |
| 1967 class C { | 3827 class C { |
| 1968 static const String F = ''; | 3828 static const String F = ''; |
| 1969 } | 3829 } |
| 1970 const int v = C.F.length; | 3830 const int v = C.F.length; |
| 1971 '''); | 3831 '''); |
| 3832 if (isStrongMode) { |
| 3833 checkElementText( |
| 3834 library, |
| 3835 r''' |
| 3836 class C { |
| 3837 static const String F = ''; |
| 3838 } |
| 3839 const int v = C.F.length; |
| 3840 '''); |
| 3841 } else { |
| 3842 checkElementText( |
| 3843 library, |
| 3844 r''' |
| 3845 class C { |
| 3846 static const String F = ''; |
| 3847 } |
| 3848 const int v = C.F.length; |
| 3849 '''); |
| 3850 } |
| 1972 } | 3851 } |
| 1973 | 3852 |
| 1974 test_const_length_ofClassConstField_imported() { | 3853 test_const_length_ofClassConstField_imported() { |
| 1975 addLibrarySource( | 3854 addLibrarySource( |
| 1976 '/a.dart', | 3855 '/a.dart', |
| 1977 r''' | 3856 r''' |
| 1978 class C { | 3857 class C { |
| 1979 static const String F = ''; | 3858 static const String F = ''; |
| 1980 } | 3859 } |
| 1981 '''); | 3860 '''); |
| 1982 checkLibrary(r''' | 3861 var library = checkLibrary(r''' |
| 1983 import 'a.dart'; | 3862 import 'a.dart'; |
| 1984 const int v = C.F.length; | 3863 const int v = C.F.length; |
| 1985 '''); | 3864 '''); |
| 3865 if (isStrongMode) { |
| 3866 checkElementText( |
| 3867 library, |
| 3868 r''' |
| 3869 import 'a.dart'; |
| 3870 const int v = C.F.length; |
| 3871 '''); |
| 3872 } else { |
| 3873 checkElementText( |
| 3874 library, |
| 3875 r''' |
| 3876 import 'a.dart'; |
| 3877 const int v = C.F.length; |
| 3878 '''); |
| 3879 } |
| 1986 } | 3880 } |
| 1987 | 3881 |
| 1988 test_const_length_ofClassConstField_imported_withPrefix() { | 3882 test_const_length_ofClassConstField_imported_withPrefix() { |
| 1989 addLibrarySource( | 3883 addLibrarySource( |
| 1990 '/a.dart', | 3884 '/a.dart', |
| 1991 r''' | 3885 r''' |
| 1992 class C { | 3886 class C { |
| 1993 static const String F = ''; | 3887 static const String F = ''; |
| 1994 } | 3888 } |
| 1995 '''); | 3889 '''); |
| 1996 checkLibrary(r''' | 3890 var library = checkLibrary(r''' |
| 1997 import 'a.dart' as p; | 3891 import 'a.dart' as p; |
| 1998 const int v = p.C.F.length; | 3892 const int v = p.C.F.length; |
| 1999 '''); | 3893 '''); |
| 3894 if (isStrongMode) { |
| 3895 checkElementText( |
| 3896 library, |
| 3897 r''' |
| 3898 import 'a.dart' as p; |
| 3899 const int v = p.C.F.length; |
| 3900 '''); |
| 3901 } else { |
| 3902 checkElementText( |
| 3903 library, |
| 3904 r''' |
| 3905 import 'a.dart' as p; |
| 3906 const int v = p.C.F.length; |
| 3907 '''); |
| 3908 } |
| 2000 } | 3909 } |
| 2001 | 3910 |
| 2002 test_const_length_ofStringLiteral() { | 3911 test_const_length_ofStringLiteral() { |
| 2003 checkLibrary(r''' | 3912 var library = checkLibrary(r''' |
| 2004 const v = 'abc'.length; | 3913 const v = 'abc'.length; |
| 2005 '''); | 3914 '''); |
| 3915 if (isStrongMode) { |
| 3916 checkElementText( |
| 3917 library, |
| 3918 r''' |
| 3919 const int v = 'abc'.length; |
| 3920 '''); |
| 3921 } else { |
| 3922 checkElementText( |
| 3923 library, |
| 3924 r''' |
| 3925 const dynamic v = 'abc'.length; |
| 3926 '''); |
| 3927 } |
| 2006 } | 3928 } |
| 2007 | 3929 |
| 2008 test_const_length_ofTopLevelVariable() { | 3930 test_const_length_ofTopLevelVariable() { |
| 2009 checkLibrary(r''' | 3931 var library = checkLibrary(r''' |
| 2010 const String S = 'abc'; | 3932 const String S = 'abc'; |
| 2011 const v = S.length; | 3933 const v = S.length; |
| 2012 '''); | 3934 '''); |
| 3935 if (isStrongMode) { |
| 3936 checkElementText( |
| 3937 library, |
| 3938 r''' |
| 3939 const String S = 'abc'; |
| 3940 const int v = S.length; |
| 3941 '''); |
| 3942 } else { |
| 3943 checkElementText( |
| 3944 library, |
| 3945 r''' |
| 3946 const String S = 'abc'; |
| 3947 const dynamic v = S.length; |
| 3948 '''); |
| 3949 } |
| 2013 } | 3950 } |
| 2014 | 3951 |
| 2015 test_const_length_ofTopLevelVariable_imported() { | 3952 test_const_length_ofTopLevelVariable_imported() { |
| 2016 addLibrarySource( | 3953 addLibrarySource( |
| 2017 '/a.dart', | 3954 '/a.dart', |
| 2018 r''' | 3955 r''' |
| 2019 const String S = 'abc'; | 3956 const String S = 'abc'; |
| 2020 '''); | 3957 '''); |
| 2021 checkLibrary(r''' | 3958 var library = checkLibrary(r''' |
| 2022 import 'a.dart'; | 3959 import 'a.dart'; |
| 2023 const v = S.length; | 3960 const v = S.length; |
| 2024 '''); | 3961 '''); |
| 3962 if (isStrongMode) { |
| 3963 checkElementText( |
| 3964 library, |
| 3965 r''' |
| 3966 import 'a.dart'; |
| 3967 const int v = S.length; |
| 3968 '''); |
| 3969 } else { |
| 3970 checkElementText( |
| 3971 library, |
| 3972 r''' |
| 3973 import 'a.dart'; |
| 3974 const dynamic v = S.length; |
| 3975 '''); |
| 3976 } |
| 2025 } | 3977 } |
| 2026 | 3978 |
| 2027 test_const_length_ofTopLevelVariable_imported_withPrefix() { | 3979 test_const_length_ofTopLevelVariable_imported_withPrefix() { |
| 2028 addLibrarySource( | 3980 addLibrarySource( |
| 2029 '/a.dart', | 3981 '/a.dart', |
| 2030 r''' | 3982 r''' |
| 2031 const String S = 'abc'; | 3983 const String S = 'abc'; |
| 2032 '''); | 3984 '''); |
| 2033 checkLibrary(r''' | 3985 var library = checkLibrary(r''' |
| 2034 import 'a.dart' as p; | 3986 import 'a.dart' as p; |
| 2035 const v = p.S.length; | 3987 const v = p.S.length; |
| 2036 '''); | 3988 '''); |
| 3989 if (isStrongMode) { |
| 3990 checkElementText( |
| 3991 library, |
| 3992 r''' |
| 3993 import 'a.dart' as p; |
| 3994 const int v = p.S.length; |
| 3995 '''); |
| 3996 } else { |
| 3997 checkElementText( |
| 3998 library, |
| 3999 r''' |
| 4000 import 'a.dart' as p; |
| 4001 const dynamic v = p.S.length; |
| 4002 '''); |
| 4003 } |
| 2037 } | 4004 } |
| 2038 | 4005 |
| 2039 test_const_length_staticMethod() { | 4006 test_const_length_staticMethod() { |
| 2040 checkLibrary(r''' | 4007 var library = checkLibrary(r''' |
| 2041 class C { | 4008 class C { |
| 2042 static int length() => 42; | 4009 static int length() => 42; |
| 2043 } | 4010 } |
| 2044 const v = C.length; | 4011 const v = C.length; |
| 2045 '''); | 4012 '''); |
| 4013 if (isStrongMode) { |
| 4014 checkElementText( |
| 4015 library, |
| 4016 r''' |
| 4017 class C { |
| 4018 static int length() {} |
| 4019 } |
| 4020 const () → int v = C.length; |
| 4021 '''); |
| 4022 } else { |
| 4023 checkElementText( |
| 4024 library, |
| 4025 r''' |
| 4026 class C { |
| 4027 static int length() {} |
| 4028 } |
| 4029 const dynamic v = C.length; |
| 4030 '''); |
| 4031 } |
| 2046 } | 4032 } |
| 2047 | 4033 |
| 2048 test_const_parameterDefaultValue_initializingFormal_functionTyped() { | 4034 test_const_parameterDefaultValue_initializingFormal_functionTyped() { |
| 2049 checkLibrary(r''' | 4035 var library = checkLibrary(r''' |
| 2050 class C { | 4036 class C { |
| 2051 final x; | 4037 final x; |
| 2052 const C({this.x: foo}); | 4038 const C({this.x: foo}); |
| 2053 } | 4039 } |
| 2054 int foo() => 42; | 4040 int foo() => 42; |
| 2055 '''); | 4041 '''); |
| 4042 if (isStrongMode) { |
| 4043 checkElementText( |
| 4044 library, |
| 4045 r''' |
| 4046 class C { |
| 4047 final dynamic x; |
| 4048 const C({dynamic this.x}); |
| 4049 } |
| 4050 int foo() {} |
| 4051 '''); |
| 4052 } else { |
| 4053 checkElementText( |
| 4054 library, |
| 4055 r''' |
| 4056 class C { |
| 4057 final dynamic x; |
| 4058 const C({dynamic this.x}); |
| 4059 } |
| 4060 int foo() {} |
| 4061 '''); |
| 4062 } |
| 2056 } | 4063 } |
| 2057 | 4064 |
| 2058 test_const_parameterDefaultValue_initializingFormal_named() { | 4065 test_const_parameterDefaultValue_initializingFormal_named() { |
| 2059 checkLibrary(r''' | 4066 var library = checkLibrary(r''' |
| 2060 class C { | 4067 class C { |
| 2061 final x; | 4068 final x; |
| 2062 const C({this.x: 1 + 2}); | 4069 const C({this.x: 1 + 2}); |
| 2063 } | 4070 } |
| 2064 '''); | 4071 '''); |
| 4072 if (isStrongMode) { |
| 4073 checkElementText( |
| 4074 library, |
| 4075 r''' |
| 4076 class C { |
| 4077 final dynamic x; |
| 4078 const C({dynamic this.x}); |
| 4079 } |
| 4080 '''); |
| 4081 } else { |
| 4082 checkElementText( |
| 4083 library, |
| 4084 r''' |
| 4085 class C { |
| 4086 final dynamic x; |
| 4087 const C({dynamic this.x}); |
| 4088 } |
| 4089 '''); |
| 4090 } |
| 2065 } | 4091 } |
| 2066 | 4092 |
| 2067 test_const_parameterDefaultValue_initializingFormal_positional() { | 4093 test_const_parameterDefaultValue_initializingFormal_positional() { |
| 2068 checkLibrary(r''' | 4094 var library = checkLibrary(r''' |
| 2069 class C { | 4095 class C { |
| 2070 final x; | 4096 final x; |
| 2071 const C([this.x = 1 + 2]); | 4097 const C([this.x = 1 + 2]); |
| 2072 } | 4098 } |
| 2073 '''); | 4099 '''); |
| 4100 if (isStrongMode) { |
| 4101 checkElementText( |
| 4102 library, |
| 4103 r''' |
| 4104 class C { |
| 4105 final dynamic x; |
| 4106 const C([dynamic this.x]); |
| 4107 } |
| 4108 '''); |
| 4109 } else { |
| 4110 checkElementText( |
| 4111 library, |
| 4112 r''' |
| 4113 class C { |
| 4114 final dynamic x; |
| 4115 const C([dynamic this.x]); |
| 4116 } |
| 4117 '''); |
| 4118 } |
| 2074 } | 4119 } |
| 2075 | 4120 |
| 2076 test_const_parameterDefaultValue_normal() { | 4121 test_const_parameterDefaultValue_normal() { |
| 2077 checkLibrary(r''' | 4122 var library = checkLibrary(r''' |
| 2078 class C { | 4123 class C { |
| 2079 const C.positional([p = 1 + 2]); | 4124 const C.positional([p = 1 + 2]); |
| 2080 const C.named({p: 1 + 2}); | 4125 const C.named({p: 1 + 2}); |
| 2081 void methodPositional([p = 1 + 2]) {} | 4126 void methodPositional([p = 1 + 2]) {} |
| 2082 void methodPositionalWithoutDefault([p]) {} | 4127 void methodPositionalWithoutDefault([p]) {} |
| 2083 void methodNamed({p: 1 + 2}) {} | 4128 void methodNamed({p: 1 + 2}) {} |
| 2084 void methodNamedWithoutDefault({p}) {} | 4129 void methodNamedWithoutDefault({p}) {} |
| 2085 } | 4130 } |
| 2086 '''); | 4131 '''); |
| 4132 if (isStrongMode) { |
| 4133 checkElementText( |
| 4134 library, |
| 4135 r''' |
| 4136 class C { |
| 4137 const C.positional([dynamic p = 1 + 2]); |
| 4138 const C.named({dynamic p: 1 + 2}); |
| 4139 void methodPositional([dynamic p = 1 + 2]) {} |
| 4140 void methodPositionalWithoutDefault([dynamic p]) {} |
| 4141 void methodNamed({dynamic p: 1 + 2}) {} |
| 4142 void methodNamedWithoutDefault({dynamic p}) {} |
| 4143 } |
| 4144 '''); |
| 4145 } else { |
| 4146 checkElementText( |
| 4147 library, |
| 4148 r''' |
| 4149 class C { |
| 4150 const C.positional([dynamic p = 1 + 2]); |
| 4151 const C.named({dynamic p: 1 + 2}); |
| 4152 void methodPositional([dynamic p = 1 + 2]) {} |
| 4153 void methodPositionalWithoutDefault([dynamic p]) {} |
| 4154 void methodNamed({dynamic p: 1 + 2}) {} |
| 4155 void methodNamedWithoutDefault({dynamic p}) {} |
| 4156 } |
| 4157 '''); |
| 4158 } |
| 2087 } | 4159 } |
| 2088 | 4160 |
| 2089 test_const_reference_staticField() { | 4161 test_const_reference_staticField() { |
| 2090 checkLibrary(r''' | 4162 var library = checkLibrary(r''' |
| 2091 class C { | 4163 class C { |
| 2092 static const int F = 42; | 4164 static const int F = 42; |
| 2093 } | 4165 } |
| 2094 const V = C.F; | 4166 const V = C.F; |
| 2095 '''); | 4167 '''); |
| 4168 if (isStrongMode) { |
| 4169 checkElementText( |
| 4170 library, |
| 4171 r''' |
| 4172 class C { |
| 4173 static const int F = 42; |
| 4174 } |
| 4175 const int V = C.F; |
| 4176 '''); |
| 4177 } else { |
| 4178 checkElementText( |
| 4179 library, |
| 4180 r''' |
| 4181 class C { |
| 4182 static const int F = 42; |
| 4183 } |
| 4184 const dynamic V = C.F; |
| 4185 '''); |
| 4186 } |
| 2096 } | 4187 } |
| 2097 | 4188 |
| 2098 test_const_reference_staticField_imported() { | 4189 test_const_reference_staticField_imported() { |
| 2099 addLibrarySource( | 4190 addLibrarySource( |
| 2100 '/a.dart', | 4191 '/a.dart', |
| 2101 r''' | 4192 r''' |
| 2102 class C { | 4193 class C { |
| 2103 static const int F = 42; | 4194 static const int F = 42; |
| 2104 } | 4195 } |
| 2105 '''); | 4196 '''); |
| 2106 checkLibrary(r''' | 4197 var library = checkLibrary(r''' |
| 2107 import 'a.dart'; | 4198 import 'a.dart'; |
| 2108 const V = C.F; | 4199 const V = C.F; |
| 2109 '''); | 4200 '''); |
| 4201 if (isStrongMode) { |
| 4202 checkElementText( |
| 4203 library, |
| 4204 r''' |
| 4205 import 'a.dart'; |
| 4206 const int V = C.F; |
| 4207 '''); |
| 4208 } else { |
| 4209 checkElementText( |
| 4210 library, |
| 4211 r''' |
| 4212 import 'a.dart'; |
| 4213 const dynamic V = C.F; |
| 4214 '''); |
| 4215 } |
| 2110 } | 4216 } |
| 2111 | 4217 |
| 2112 test_const_reference_staticField_imported_withPrefix() { | 4218 test_const_reference_staticField_imported_withPrefix() { |
| 2113 addLibrarySource( | 4219 addLibrarySource( |
| 2114 '/a.dart', | 4220 '/a.dart', |
| 2115 r''' | 4221 r''' |
| 2116 class C { | 4222 class C { |
| 2117 static const int F = 42; | 4223 static const int F = 42; |
| 2118 } | 4224 } |
| 2119 '''); | 4225 '''); |
| 2120 checkLibrary(r''' | 4226 var library = checkLibrary(r''' |
| 2121 import 'a.dart' as p; | 4227 import 'a.dart' as p; |
| 2122 const V = p.C.F; | 4228 const V = p.C.F; |
| 2123 '''); | 4229 '''); |
| 4230 if (isStrongMode) { |
| 4231 checkElementText( |
| 4232 library, |
| 4233 r''' |
| 4234 import 'a.dart' as p; |
| 4235 const int V = p.C.F; |
| 4236 '''); |
| 4237 } else { |
| 4238 checkElementText( |
| 4239 library, |
| 4240 r''' |
| 4241 import 'a.dart' as p; |
| 4242 const dynamic V = p.C.F; |
| 4243 '''); |
| 4244 } |
| 2124 } | 4245 } |
| 2125 | 4246 |
| 2126 test_const_reference_staticMethod() { | 4247 test_const_reference_staticMethod() { |
| 2127 checkLibrary(r''' | 4248 var library = checkLibrary(r''' |
| 2128 class C { | 4249 class C { |
| 2129 static int m(int a, String b) => 42; | 4250 static int m(int a, String b) => 42; |
| 2130 } | 4251 } |
| 2131 const V = C.m; | 4252 const V = C.m; |
| 2132 '''); | 4253 '''); |
| 4254 if (isStrongMode) { |
| 4255 checkElementText( |
| 4256 library, |
| 4257 r''' |
| 4258 class C { |
| 4259 static int m(int a, String b) {} |
| 4260 } |
| 4261 const (int, String) → int V = C.m; |
| 4262 '''); |
| 4263 } else { |
| 4264 checkElementText( |
| 4265 library, |
| 4266 r''' |
| 4267 class C { |
| 4268 static int m(int a, String b) {} |
| 4269 } |
| 4270 const dynamic V = C.m; |
| 4271 '''); |
| 4272 } |
| 2133 } | 4273 } |
| 2134 | 4274 |
| 2135 test_const_reference_staticMethod_imported() { | 4275 test_const_reference_staticMethod_imported() { |
| 2136 addLibrarySource( | 4276 addLibrarySource( |
| 2137 '/a.dart', | 4277 '/a.dart', |
| 2138 r''' | 4278 r''' |
| 2139 class C { | 4279 class C { |
| 2140 static int m(int a, String b) => 42; | 4280 static int m(int a, String b) => 42; |
| 2141 } | 4281 } |
| 2142 '''); | 4282 '''); |
| 2143 checkLibrary(r''' | 4283 var library = checkLibrary(r''' |
| 2144 import 'a.dart'; | 4284 import 'a.dart'; |
| 2145 const V = C.m; | 4285 const V = C.m; |
| 2146 '''); | 4286 '''); |
| 4287 if (isStrongMode) { |
| 4288 checkElementText( |
| 4289 library, |
| 4290 r''' |
| 4291 import 'a.dart'; |
| 4292 const (int, String) → int V = C.m; |
| 4293 '''); |
| 4294 } else { |
| 4295 checkElementText( |
| 4296 library, |
| 4297 r''' |
| 4298 import 'a.dart'; |
| 4299 const dynamic V = C.m; |
| 4300 '''); |
| 4301 } |
| 2147 } | 4302 } |
| 2148 | 4303 |
| 2149 test_const_reference_staticMethod_imported_withPrefix() { | 4304 test_const_reference_staticMethod_imported_withPrefix() { |
| 2150 addLibrarySource( | 4305 addLibrarySource( |
| 2151 '/a.dart', | 4306 '/a.dart', |
| 2152 r''' | 4307 r''' |
| 2153 class C { | 4308 class C { |
| 2154 static int m(int a, String b) => 42; | 4309 static int m(int a, String b) => 42; |
| 2155 } | 4310 } |
| 2156 '''); | 4311 '''); |
| 2157 checkLibrary(r''' | 4312 var library = checkLibrary(r''' |
| 2158 import 'a.dart' as p; | 4313 import 'a.dart' as p; |
| 2159 const V = p.C.m; | 4314 const V = p.C.m; |
| 2160 '''); | 4315 '''); |
| 4316 if (isStrongMode) { |
| 4317 checkElementText( |
| 4318 library, |
| 4319 r''' |
| 4320 import 'a.dart' as p; |
| 4321 const (int, String) → int V = p.C.m; |
| 4322 '''); |
| 4323 } else { |
| 4324 checkElementText( |
| 4325 library, |
| 4326 r''' |
| 4327 import 'a.dart' as p; |
| 4328 const dynamic V = p.C.m; |
| 4329 '''); |
| 4330 } |
| 2161 } | 4331 } |
| 2162 | 4332 |
| 2163 test_const_reference_topLevelFunction() { | 4333 test_const_reference_topLevelFunction() { |
| 2164 checkLibrary(r''' | 4334 var library = checkLibrary(r''' |
| 2165 foo() {} | 4335 foo() {} |
| 2166 const V = foo; | 4336 const V = foo; |
| 2167 '''); | 4337 '''); |
| 4338 if (isStrongMode) { |
| 4339 checkElementText( |
| 4340 library, |
| 4341 r''' |
| 4342 const () → dynamic V = foo; |
| 4343 dynamic foo() {} |
| 4344 '''); |
| 4345 } else { |
| 4346 checkElementText( |
| 4347 library, |
| 4348 r''' |
| 4349 const dynamic V = foo; |
| 4350 dynamic foo() {} |
| 4351 '''); |
| 4352 } |
| 2168 } | 4353 } |
| 2169 | 4354 |
| 2170 test_const_reference_topLevelFunction_imported() { | 4355 test_const_reference_topLevelFunction_imported() { |
| 2171 addLibrarySource( | 4356 addLibrarySource( |
| 2172 '/a.dart', | 4357 '/a.dart', |
| 2173 r''' | 4358 r''' |
| 2174 foo() {} | 4359 foo() {} |
| 2175 '''); | 4360 '''); |
| 2176 checkLibrary(r''' | 4361 var library = checkLibrary(r''' |
| 2177 import 'a.dart'; | 4362 import 'a.dart'; |
| 2178 const V = foo; | 4363 const V = foo; |
| 2179 '''); | 4364 '''); |
| 4365 if (isStrongMode) { |
| 4366 checkElementText( |
| 4367 library, |
| 4368 r''' |
| 4369 import 'a.dart'; |
| 4370 const () → dynamic V = foo; |
| 4371 '''); |
| 4372 } else { |
| 4373 checkElementText( |
| 4374 library, |
| 4375 r''' |
| 4376 import 'a.dart'; |
| 4377 const dynamic V = foo; |
| 4378 '''); |
| 4379 } |
| 2180 } | 4380 } |
| 2181 | 4381 |
| 2182 test_const_reference_topLevelFunction_imported_withPrefix() { | 4382 test_const_reference_topLevelFunction_imported_withPrefix() { |
| 2183 addLibrarySource( | 4383 addLibrarySource( |
| 2184 '/a.dart', | 4384 '/a.dart', |
| 2185 r''' | 4385 r''' |
| 2186 foo() {} | 4386 foo() {} |
| 2187 '''); | 4387 '''); |
| 2188 checkLibrary(r''' | 4388 var library = checkLibrary(r''' |
| 2189 import 'a.dart' as p; | 4389 import 'a.dart' as p; |
| 2190 const V = p.foo; | 4390 const V = p.foo; |
| 2191 '''); | 4391 '''); |
| 4392 if (isStrongMode) { |
| 4393 checkElementText( |
| 4394 library, |
| 4395 r''' |
| 4396 import 'a.dart' as p; |
| 4397 const () → dynamic V = p.foo; |
| 4398 '''); |
| 4399 } else { |
| 4400 checkElementText( |
| 4401 library, |
| 4402 r''' |
| 4403 import 'a.dart' as p; |
| 4404 const dynamic V = p.foo; |
| 4405 '''); |
| 4406 } |
| 2192 } | 4407 } |
| 2193 | 4408 |
| 2194 test_const_reference_topLevelVariable() { | 4409 test_const_reference_topLevelVariable() { |
| 2195 checkLibrary(r''' | 4410 var library = checkLibrary(r''' |
| 2196 const A = 1; | 4411 const A = 1; |
| 2197 const B = A + 2; | 4412 const B = A + 2; |
| 2198 '''); | 4413 '''); |
| 4414 if (isStrongMode) { |
| 4415 checkElementText( |
| 4416 library, |
| 4417 r''' |
| 4418 const int A = 1; |
| 4419 const int B = A + 2; |
| 4420 '''); |
| 4421 } else { |
| 4422 checkElementText( |
| 4423 library, |
| 4424 r''' |
| 4425 const dynamic A = 1; |
| 4426 const dynamic B = A + 2; |
| 4427 '''); |
| 4428 } |
| 2199 } | 4429 } |
| 2200 | 4430 |
| 2201 test_const_reference_topLevelVariable_imported() { | 4431 test_const_reference_topLevelVariable_imported() { |
| 2202 addLibrarySource( | 4432 addLibrarySource( |
| 2203 '/a.dart', | 4433 '/a.dart', |
| 2204 r''' | 4434 r''' |
| 2205 const A = 1; | 4435 const A = 1; |
| 2206 '''); | 4436 '''); |
| 2207 checkLibrary(r''' | 4437 var library = checkLibrary(r''' |
| 2208 import 'a.dart'; | 4438 import 'a.dart'; |
| 2209 const B = A + 2; | 4439 const B = A + 2; |
| 2210 '''); | 4440 '''); |
| 4441 if (isStrongMode) { |
| 4442 checkElementText( |
| 4443 library, |
| 4444 r''' |
| 4445 import 'a.dart'; |
| 4446 const int B = A + 2; |
| 4447 '''); |
| 4448 } else { |
| 4449 checkElementText( |
| 4450 library, |
| 4451 r''' |
| 4452 import 'a.dart'; |
| 4453 const dynamic B = A + 2; |
| 4454 '''); |
| 4455 } |
| 2211 } | 4456 } |
| 2212 | 4457 |
| 2213 test_const_reference_topLevelVariable_imported_withPrefix() { | 4458 test_const_reference_topLevelVariable_imported_withPrefix() { |
| 2214 addLibrarySource( | 4459 addLibrarySource( |
| 2215 '/a.dart', | 4460 '/a.dart', |
| 2216 r''' | 4461 r''' |
| 2217 const A = 1; | 4462 const A = 1; |
| 2218 '''); | 4463 '''); |
| 2219 checkLibrary(r''' | 4464 var library = checkLibrary(r''' |
| 2220 import 'a.dart' as p; | 4465 import 'a.dart' as p; |
| 2221 const B = p.A + 2; | 4466 const B = p.A + 2; |
| 2222 '''); | 4467 '''); |
| 4468 if (isStrongMode) { |
| 4469 checkElementText( |
| 4470 library, |
| 4471 r''' |
| 4472 import 'a.dart' as p; |
| 4473 const int B = p.A + 2; |
| 4474 '''); |
| 4475 } else { |
| 4476 checkElementText( |
| 4477 library, |
| 4478 r''' |
| 4479 import 'a.dart' as p; |
| 4480 const dynamic B = p.A + 2; |
| 4481 '''); |
| 4482 } |
| 2223 } | 4483 } |
| 2224 | 4484 |
| 2225 test_const_reference_type() { | 4485 test_const_reference_type() { |
| 2226 checkLibrary(r''' | 4486 var library = checkLibrary(r''' |
| 2227 class C {} | 4487 class C {} |
| 2228 class D<T> {} | 4488 class D<T> {} |
| 2229 enum E {a, b, c} | 4489 enum E {a, b, c} |
| 2230 typedef F(int a, String b); | 4490 typedef F(int a, String b); |
| 2231 const vDynamic = dynamic; | 4491 const vDynamic = dynamic; |
| 2232 const vNull = Null; | 4492 const vNull = Null; |
| 2233 const vObject = Object; | 4493 const vObject = Object; |
| 2234 const vClass = C; | 4494 const vClass = C; |
| 2235 const vGenericClass = D; | 4495 const vGenericClass = D; |
| 2236 const vEnum = E; | 4496 const vEnum = E; |
| 2237 const vFunctionTypeAlias = F; | 4497 const vFunctionTypeAlias = F; |
| 2238 '''); | 4498 '''); |
| 4499 if (isStrongMode) { |
| 4500 checkElementText( |
| 4501 library, |
| 4502 r''' |
| 4503 typedef dynamic F(int a, String b); |
| 4504 enum E { |
| 4505 final int index; |
| 4506 static const List<E> values; |
| 4507 static const E a; |
| 4508 static const E b; |
| 4509 static const E c; |
| 4510 } |
| 4511 class C { |
| 4512 } |
| 4513 class D<T> { |
| 4514 } |
| 4515 const Type vDynamic = dynamic; |
| 4516 const Type vNull = Null; |
| 4517 const Type vObject = Object; |
| 4518 const Type vClass = C; |
| 4519 const Type vGenericClass = D; |
| 4520 const Type vEnum = E; |
| 4521 const Type vFunctionTypeAlias = F; |
| 4522 '''); |
| 4523 } else { |
| 4524 checkElementText( |
| 4525 library, |
| 4526 r''' |
| 4527 typedef dynamic F(int a, String b); |
| 4528 enum E { |
| 4529 final int index; |
| 4530 static const List<E> values; |
| 4531 static const E a; |
| 4532 static const E b; |
| 4533 static const E c; |
| 4534 } |
| 4535 class C { |
| 4536 } |
| 4537 class D<T> { |
| 4538 } |
| 4539 const dynamic vDynamic = dynamic; |
| 4540 const dynamic vNull = Null; |
| 4541 const dynamic vObject = Object; |
| 4542 const dynamic vClass = C; |
| 4543 const dynamic vGenericClass = D; |
| 4544 const dynamic vEnum = E; |
| 4545 const dynamic vFunctionTypeAlias = F; |
| 4546 '''); |
| 4547 } |
| 2239 } | 4548 } |
| 2240 | 4549 |
| 2241 test_const_reference_type_functionType() { | 4550 test_const_reference_type_functionType() { |
| 2242 checkLibrary(r''' | 4551 var library = checkLibrary(r''' |
| 2243 typedef F(); | 4552 typedef F(); |
| 2244 class C { | 4553 class C { |
| 2245 final f = <F>[]; | 4554 final f = <F>[]; |
| 2246 } | 4555 } |
| 2247 '''); | 4556 '''); |
| 4557 if (isStrongMode) { |
| 4558 checkElementText( |
| 4559 library, |
| 4560 r''' |
| 4561 typedef dynamic F(); |
| 4562 class C { |
| 4563 final List<F> f = const <F>[]; |
| 4564 } |
| 4565 '''); |
| 4566 } else { |
| 4567 checkElementText( |
| 4568 library, |
| 4569 r''' |
| 4570 typedef dynamic F(); |
| 4571 class C { |
| 4572 final dynamic f = const <F>[]; |
| 4573 } |
| 4574 '''); |
| 4575 } |
| 2248 } | 4576 } |
| 2249 | 4577 |
| 2250 test_const_reference_type_imported() { | 4578 test_const_reference_type_imported() { |
| 2251 addLibrarySource( | 4579 addLibrarySource( |
| 2252 '/a.dart', | 4580 '/a.dart', |
| 2253 r''' | 4581 r''' |
| 2254 class C {} | 4582 class C {} |
| 2255 enum E {a, b, c} | 4583 enum E {a, b, c} |
| 2256 typedef F(int a, String b); | 4584 typedef F(int a, String b); |
| 2257 '''); | 4585 '''); |
| 2258 checkLibrary(r''' | 4586 var library = checkLibrary(r''' |
| 2259 import 'a.dart'; | 4587 import 'a.dart'; |
| 2260 const vClass = C; | 4588 const vClass = C; |
| 2261 const vEnum = E; | 4589 const vEnum = E; |
| 2262 const vFunctionTypeAlias = F; | 4590 const vFunctionTypeAlias = F; |
| 2263 '''); | 4591 '''); |
| 4592 if (isStrongMode) { |
| 4593 checkElementText( |
| 4594 library, |
| 4595 r''' |
| 4596 import 'a.dart'; |
| 4597 const Type vClass = C; |
| 4598 const Type vEnum = E; |
| 4599 const Type vFunctionTypeAlias = F; |
| 4600 '''); |
| 4601 } else { |
| 4602 checkElementText( |
| 4603 library, |
| 4604 r''' |
| 4605 import 'a.dart'; |
| 4606 const dynamic vClass = C; |
| 4607 const dynamic vEnum = E; |
| 4608 const dynamic vFunctionTypeAlias = F; |
| 4609 '''); |
| 4610 } |
| 2264 } | 4611 } |
| 2265 | 4612 |
| 2266 test_const_reference_type_imported_withPrefix() { | 4613 test_const_reference_type_imported_withPrefix() { |
| 2267 addLibrarySource( | 4614 addLibrarySource( |
| 2268 '/a.dart', | 4615 '/a.dart', |
| 2269 r''' | 4616 r''' |
| 2270 class C {} | 4617 class C {} |
| 2271 enum E {a, b, c} | 4618 enum E {a, b, c} |
| 2272 typedef F(int a, String b); | 4619 typedef F(int a, String b); |
| 2273 '''); | 4620 '''); |
| 2274 checkLibrary(r''' | 4621 var library = checkLibrary(r''' |
| 2275 import 'a.dart' as p; | 4622 import 'a.dart' as p; |
| 2276 const vClass = p.C; | 4623 const vClass = p.C; |
| 2277 const vEnum = p.E; | 4624 const vEnum = p.E; |
| 2278 const vFunctionTypeAlias = p.F; | 4625 const vFunctionTypeAlias = p.F; |
| 2279 '''); | 4626 '''); |
| 4627 if (isStrongMode) { |
| 4628 checkElementText( |
| 4629 library, |
| 4630 r''' |
| 4631 import 'a.dart' as p; |
| 4632 const Type vClass = p.C; |
| 4633 const Type vEnum = p.E; |
| 4634 const Type vFunctionTypeAlias = p.F; |
| 4635 '''); |
| 4636 } else { |
| 4637 checkElementText( |
| 4638 library, |
| 4639 r''' |
| 4640 import 'a.dart' as p; |
| 4641 const dynamic vClass = p.C; |
| 4642 const dynamic vEnum = p.E; |
| 4643 const dynamic vFunctionTypeAlias = p.F; |
| 4644 '''); |
| 4645 } |
| 2280 } | 4646 } |
| 2281 | 4647 |
| 2282 test_const_reference_type_typeParameter() { | 4648 test_const_reference_type_typeParameter() { |
| 2283 checkLibrary(r''' | 4649 var library = checkLibrary(r''' |
| 2284 class C<T> { | 4650 class C<T> { |
| 2285 final f = <T>[]; | 4651 final f = <T>[]; |
| 2286 } | 4652 } |
| 2287 '''); | 4653 '''); |
| 4654 if (isStrongMode) { |
| 4655 checkElementText( |
| 4656 library, |
| 4657 r''' |
| 4658 class C<T> { |
| 4659 final List<T> f = const <T>[]; |
| 4660 } |
| 4661 '''); |
| 4662 } else { |
| 4663 checkElementText( |
| 4664 library, |
| 4665 r''' |
| 4666 class C<T> { |
| 4667 final dynamic f = const <T>[]; |
| 4668 } |
| 4669 '''); |
| 4670 } |
| 2288 } | 4671 } |
| 2289 | 4672 |
| 2290 test_const_reference_unresolved_prefix0() { | 4673 test_const_reference_unresolved_prefix0() { |
| 2291 checkLibrary( | 4674 var library = checkLibrary( |
| 2292 r''' | 4675 r''' |
| 2293 const V = foo; | 4676 const V = foo; |
| 2294 ''', | 4677 ''', |
| 2295 allowErrors: true); | 4678 allowErrors: true); |
| 4679 if (isStrongMode) { |
| 4680 checkElementText( |
| 4681 library, |
| 4682 r''' |
| 4683 const dynamic V = foo; |
| 4684 '''); |
| 4685 } else { |
| 4686 checkElementText( |
| 4687 library, |
| 4688 r''' |
| 4689 const dynamic V = foo; |
| 4690 '''); |
| 4691 } |
| 2296 } | 4692 } |
| 2297 | 4693 |
| 2298 test_const_reference_unresolved_prefix1() { | 4694 test_const_reference_unresolved_prefix1() { |
| 2299 checkLibrary( | 4695 var library = checkLibrary( |
| 2300 r''' | 4696 r''' |
| 2301 class C {} | 4697 class C {} |
| 2302 const v = C.foo; | 4698 const v = C.foo; |
| 2303 ''', | 4699 ''', |
| 2304 allowErrors: true); | 4700 allowErrors: true); |
| 4701 if (isStrongMode) { |
| 4702 checkElementText( |
| 4703 library, |
| 4704 r''' |
| 4705 class C { |
| 4706 } |
| 4707 const dynamic v = C.foo; |
| 4708 '''); |
| 4709 } else { |
| 4710 checkElementText( |
| 4711 library, |
| 4712 r''' |
| 4713 class C { |
| 4714 } |
| 4715 const dynamic v = C.foo; |
| 4716 '''); |
| 4717 } |
| 2305 } | 4718 } |
| 2306 | 4719 |
| 2307 test_const_reference_unresolved_prefix2() { | 4720 test_const_reference_unresolved_prefix2() { |
| 2308 addLibrarySource( | 4721 addLibrarySource( |
| 2309 '/foo.dart', | 4722 '/foo.dart', |
| 2310 ''' | 4723 ''' |
| 2311 class C {} | 4724 class C {} |
| 2312 '''); | 4725 '''); |
| 2313 checkLibrary( | 4726 var library = checkLibrary( |
| 2314 r''' | 4727 r''' |
| 2315 import 'foo.dart' as p; | 4728 import 'foo.dart' as p; |
| 2316 const v = p.C.foo; | 4729 const v = p.C.foo; |
| 2317 ''', | 4730 ''', |
| 2318 allowErrors: true); | 4731 allowErrors: true); |
| 4732 if (isStrongMode) { |
| 4733 checkElementText( |
| 4734 library, |
| 4735 r''' |
| 4736 import 'foo.dart' as p; |
| 4737 const dynamic v = p.C.foo; |
| 4738 '''); |
| 4739 } else { |
| 4740 checkElementText( |
| 4741 library, |
| 4742 r''' |
| 4743 import 'foo.dart' as p; |
| 4744 const dynamic v = p.C.foo; |
| 4745 '''); |
| 4746 } |
| 2319 } | 4747 } |
| 2320 | 4748 |
| 2321 test_const_topLevel_binary() { | 4749 test_const_topLevel_binary() { |
| 2322 checkLibrary(r''' | 4750 var library = checkLibrary(r''' |
| 2323 const vEqual = 1 == 2; | 4751 const vEqual = 1 == 2; |
| 2324 const vAnd = true && false; | 4752 const vAnd = true && false; |
| 2325 const vOr = false || true; | 4753 const vOr = false || true; |
| 2326 const vBitXor = 1 ^ 2; | 4754 const vBitXor = 1 ^ 2; |
| 2327 const vBitAnd = 1 & 2; | 4755 const vBitAnd = 1 & 2; |
| 2328 const vBitOr = 1 | 2; | 4756 const vBitOr = 1 | 2; |
| 2329 const vBitShiftLeft = 1 << 2; | 4757 const vBitShiftLeft = 1 << 2; |
| 2330 const vBitShiftRight = 1 >> 2; | 4758 const vBitShiftRight = 1 >> 2; |
| 2331 const vAdd = 1 + 2; | 4759 const vAdd = 1 + 2; |
| 2332 const vSubtract = 1 - 2; | 4760 const vSubtract = 1 - 2; |
| 2333 const vMiltiply = 1 * 2; | 4761 const vMiltiply = 1 * 2; |
| 2334 const vDivide = 1 / 2; | 4762 const vDivide = 1 / 2; |
| 2335 const vFloorDivide = 1 ~/ 2; | 4763 const vFloorDivide = 1 ~/ 2; |
| 2336 const vModulo = 1 % 2; | 4764 const vModulo = 1 % 2; |
| 2337 const vGreater = 1 > 2; | 4765 const vGreater = 1 > 2; |
| 2338 const vGreaterEqual = 1 >= 2; | 4766 const vGreaterEqual = 1 >= 2; |
| 2339 const vLess = 1 < 2; | 4767 const vLess = 1 < 2; |
| 2340 const vLessEqual = 1 <= 2; | 4768 const vLessEqual = 1 <= 2; |
| 2341 '''); | 4769 '''); |
| 4770 if (isStrongMode) { |
| 4771 checkElementText( |
| 4772 library, |
| 4773 r''' |
| 4774 const bool vEqual = 1 == 2; |
| 4775 const bool vAnd = true && false; |
| 4776 const bool vOr = false || true; |
| 4777 const int vBitXor = 1 ^ 2; |
| 4778 const int vBitAnd = 1 & 2; |
| 4779 const int vBitOr = 1 | 2; |
| 4780 const int vBitShiftLeft = 1 << 2; |
| 4781 const int vBitShiftRight = 1 >> 2; |
| 4782 const int vAdd = 1 + 2; |
| 4783 const int vSubtract = 1 - 2; |
| 4784 const int vMiltiply = 1 * 2; |
| 4785 const num vDivide = 1 / 2; |
| 4786 const int vFloorDivide = 1 ~/ 2; |
| 4787 const int vModulo = 1 % 2; |
| 4788 const bool vGreater = 1 > 2; |
| 4789 const bool vGreaterEqual = 1 >= 2; |
| 4790 const bool vLess = 1 < 2; |
| 4791 const bool vLessEqual = 1 <= 2; |
| 4792 '''); |
| 4793 } else { |
| 4794 checkElementText( |
| 4795 library, |
| 4796 r''' |
| 4797 const dynamic vEqual = 1 == 2; |
| 4798 const dynamic vAnd = true && false; |
| 4799 const dynamic vOr = false || true; |
| 4800 const dynamic vBitXor = 1 ^ 2; |
| 4801 const dynamic vBitAnd = 1 & 2; |
| 4802 const dynamic vBitOr = 1 | 2; |
| 4803 const dynamic vBitShiftLeft = 1 << 2; |
| 4804 const dynamic vBitShiftRight = 1 >> 2; |
| 4805 const dynamic vAdd = 1 + 2; |
| 4806 const dynamic vSubtract = 1 - 2; |
| 4807 const dynamic vMiltiply = 1 * 2; |
| 4808 const dynamic vDivide = 1 / 2; |
| 4809 const dynamic vFloorDivide = 1 ~/ 2; |
| 4810 const dynamic vModulo = 1 % 2; |
| 4811 const dynamic vGreater = 1 > 2; |
| 4812 const dynamic vGreaterEqual = 1 >= 2; |
| 4813 const dynamic vLess = 1 < 2; |
| 4814 const dynamic vLessEqual = 1 <= 2; |
| 4815 '''); |
| 4816 } |
| 2342 } | 4817 } |
| 2343 | 4818 |
| 2344 test_const_topLevel_conditional() { | 4819 test_const_topLevel_conditional() { |
| 2345 checkLibrary(r''' | 4820 var library = checkLibrary(r''' |
| 2346 const vConditional = (1 == 2) ? 11 : 22; | 4821 const vConditional = (1 == 2) ? 11 : 22; |
| 2347 '''); | 4822 '''); |
| 4823 if (isStrongMode) { |
| 4824 checkElementText( |
| 4825 library, |
| 4826 r''' |
| 4827 const int vConditional = 1 == 2 ? 11 : 22; |
| 4828 '''); |
| 4829 } else { |
| 4830 checkElementText( |
| 4831 library, |
| 4832 r''' |
| 4833 const dynamic vConditional = 1 == 2 ? 11 : 22; |
| 4834 '''); |
| 4835 } |
| 2348 } | 4836 } |
| 2349 | 4837 |
| 2350 test_const_topLevel_identical() { | 4838 test_const_topLevel_identical() { |
| 2351 checkLibrary(r''' | 4839 var library = checkLibrary(r''' |
| 2352 const vIdentical = (1 == 2) ? 11 : 22; | 4840 const vIdentical = (1 == 2) ? 11 : 22; |
| 2353 '''); | 4841 '''); |
| 4842 if (isStrongMode) { |
| 4843 checkElementText( |
| 4844 library, |
| 4845 r''' |
| 4846 const int vIdentical = 1 == 2 ? 11 : 22; |
| 4847 '''); |
| 4848 } else { |
| 4849 checkElementText( |
| 4850 library, |
| 4851 r''' |
| 4852 const dynamic vIdentical = 1 == 2 ? 11 : 22; |
| 4853 '''); |
| 4854 } |
| 2354 } | 4855 } |
| 2355 | 4856 |
| 2356 test_const_topLevel_ifNull() { | 4857 test_const_topLevel_ifNull() { |
| 2357 checkLibrary(r''' | 4858 var library = checkLibrary(r''' |
| 2358 const vIfNull = 1 ?? 2.0; | 4859 const vIfNull = 1 ?? 2.0; |
| 2359 '''); | 4860 '''); |
| 4861 if (isStrongMode) { |
| 4862 checkElementText( |
| 4863 library, |
| 4864 r''' |
| 4865 const num vIfNull = 1 ?? 2.0; |
| 4866 '''); |
| 4867 } else { |
| 4868 checkElementText( |
| 4869 library, |
| 4870 r''' |
| 4871 const dynamic vIfNull = 1 ?? 2.0; |
| 4872 '''); |
| 4873 } |
| 2360 } | 4874 } |
| 2361 | 4875 |
| 2362 test_const_topLevel_literal() { | 4876 test_const_topLevel_literal() { |
| 2363 checkLibrary(r''' | 4877 var library = checkLibrary(r''' |
| 2364 const vNull = null; | 4878 const vNull = null; |
| 2365 const vBoolFalse = false; | 4879 const vBoolFalse = false; |
| 2366 const vBoolTrue = true; | 4880 const vBoolTrue = true; |
| 2367 const vInt = 1; | 4881 const vInt = 1; |
| 2368 const vIntLong = 0x9876543210987654321; | 4882 const vIntLong = 0x9876543210987654321; |
| 2369 const vDouble = 2.3; | 4883 const vDouble = 2.3; |
| 2370 const vString = 'abc'; | 4884 const vString = 'abc'; |
| 2371 const vStringConcat = 'aaa' 'bbb'; | 4885 const vStringConcat = 'aaa' 'bbb'; |
| 2372 const vStringInterpolation = 'aaa ${true} ${42} bbb'; | 4886 const vStringInterpolation = 'aaa ${true} ${42} bbb'; |
| 2373 const vSymbol = #aaa.bbb.ccc; | 4887 const vSymbol = #aaa.bbb.ccc; |
| 2374 '''); | 4888 '''); |
| 4889 if (isStrongMode) { |
| 4890 checkElementText( |
| 4891 library, |
| 4892 r''' |
| 4893 const dynamic vNull = null; |
| 4894 const bool vBoolFalse = false; |
| 4895 const bool vBoolTrue = true; |
| 4896 const int vInt = 1; |
| 4897 const int vIntLong = 44998905507923676709665; |
| 4898 const double vDouble = 2.3; |
| 4899 const String vString = 'abc'; |
| 4900 const String vStringConcat = 'aaabbb'; |
| 4901 const String vStringInterpolation = 'aaa ${true} ${42} bbb'; |
| 4902 const Symbol vSymbol = #aaa.bbb.ccc; |
| 4903 '''); |
| 4904 } else { |
| 4905 checkElementText( |
| 4906 library, |
| 4907 r''' |
| 4908 const dynamic vNull = null; |
| 4909 const dynamic vBoolFalse = false; |
| 4910 const dynamic vBoolTrue = true; |
| 4911 const dynamic vInt = 1; |
| 4912 const dynamic vIntLong = 44998905507923676709665; |
| 4913 const dynamic vDouble = 2.3; |
| 4914 const dynamic vString = 'abc'; |
| 4915 const dynamic vStringConcat = 'aaabbb'; |
| 4916 const dynamic vStringInterpolation = 'aaa ${true} ${42} bbb'; |
| 4917 const dynamic vSymbol = #aaa.bbb.ccc; |
| 4918 '''); |
| 4919 } |
| 2375 } | 4920 } |
| 2376 | 4921 |
| 2377 test_const_topLevel_prefix() { | 4922 test_const_topLevel_prefix() { |
| 2378 checkLibrary(r''' | 4923 var library = checkLibrary(r''' |
| 2379 const vNotEqual = 1 != 2; | 4924 const vNotEqual = 1 != 2; |
| 2380 const vNot = !true; | 4925 const vNot = !true; |
| 2381 const vNegate = -1; | 4926 const vNegate = -1; |
| 2382 const vComplement = ~1; | 4927 const vComplement = ~1; |
| 2383 '''); | 4928 '''); |
| 4929 if (isStrongMode) { |
| 4930 checkElementText( |
| 4931 library, |
| 4932 r''' |
| 4933 const bool vNotEqual = 1 != 2; |
| 4934 const bool vNot = !true; |
| 4935 const int vNegate = -1; |
| 4936 const int vComplement = ~1; |
| 4937 '''); |
| 4938 } else { |
| 4939 checkElementText( |
| 4940 library, |
| 4941 r''' |
| 4942 const dynamic vNotEqual = 1 != 2; |
| 4943 const dynamic vNot = !true; |
| 4944 const dynamic vNegate = -1; |
| 4945 const dynamic vComplement = ~1; |
| 4946 '''); |
| 4947 } |
| 2384 } | 4948 } |
| 2385 | 4949 |
| 2386 test_const_topLevel_super() { | 4950 test_const_topLevel_super() { |
| 2387 checkLibrary(r''' | 4951 var library = checkLibrary(r''' |
| 2388 const vSuper = super; | 4952 const vSuper = super; |
| 2389 '''); | 4953 '''); |
| 4954 if (isStrongMode) { |
| 4955 checkElementText( |
| 4956 library, |
| 4957 r''' |
| 4958 const dynamic vSuper = super; |
| 4959 '''); |
| 4960 } else { |
| 4961 checkElementText( |
| 4962 library, |
| 4963 r''' |
| 4964 const dynamic vSuper = super; |
| 4965 '''); |
| 4966 } |
| 2390 } | 4967 } |
| 2391 | 4968 |
| 2392 test_const_topLevel_this() { | 4969 test_const_topLevel_this() { |
| 2393 checkLibrary(r''' | 4970 var library = checkLibrary(r''' |
| 2394 const vThis = this; | 4971 const vThis = this; |
| 2395 '''); | 4972 '''); |
| 4973 if (isStrongMode) { |
| 4974 checkElementText( |
| 4975 library, |
| 4976 r''' |
| 4977 const dynamic vThis = this; |
| 4978 '''); |
| 4979 } else { |
| 4980 checkElementText( |
| 4981 library, |
| 4982 r''' |
| 4983 const dynamic vThis = this; |
| 4984 '''); |
| 4985 } |
| 2396 } | 4986 } |
| 2397 | 4987 |
| 2398 test_const_topLevel_typedList() { | 4988 test_const_topLevel_typedList() { |
| 2399 checkLibrary(r''' | 4989 var library = checkLibrary(r''' |
| 2400 const vNull = const <Null>[]; | 4990 const vNull = const <Null>[]; |
| 2401 const vDynamic = const <dynamic>[1, 2, 3]; | 4991 const vDynamic = const <dynamic>[1, 2, 3]; |
| 2402 const vInterfaceNoTypeParameters = const <int>[1, 2, 3]; | 4992 const vInterfaceNoTypeParameters = const <int>[1, 2, 3]; |
| 2403 const vInterfaceNoTypeArguments = const <List>[]; | 4993 const vInterfaceNoTypeArguments = const <List>[]; |
| 2404 const vInterfaceWithTypeArguments = const <List<String>>[]; | 4994 const vInterfaceWithTypeArguments = const <List<String>>[]; |
| 2405 const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[]; | 4995 const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[]; |
| 2406 '''); | 4996 '''); |
| 4997 if (isStrongMode) { |
| 4998 checkElementText( |
| 4999 library, |
| 5000 r''' |
| 5001 const List<Null> vNull = const <Null>[]; |
| 5002 const List<dynamic> vDynamic = const <dynamic>[1, 2, 3]; |
| 5003 const List<int> vInterfaceNoTypeParameters = const <int>[1, 2, 3]; |
| 5004 const List<List<dynamic>> vInterfaceNoTypeArguments = const <List>[]; |
| 5005 const List<List<String>> vInterfaceWithTypeArguments = const <List<String>>[]; |
| 5006 const List<Map<int, List<String>>> vInterfaceWithTypeArguments2 = const <Map<int
, List<String>>>[]; |
| 5007 '''); |
| 5008 } else { |
| 5009 checkElementText( |
| 5010 library, |
| 5011 r''' |
| 5012 const dynamic vNull = const <Null>[]; |
| 5013 const dynamic vDynamic = const <dynamic>[1, 2, 3]; |
| 5014 const dynamic vInterfaceNoTypeParameters = const <int>[1, 2, 3]; |
| 5015 const dynamic vInterfaceNoTypeArguments = const <List>[]; |
| 5016 const dynamic vInterfaceWithTypeArguments = const <List<String>>[]; |
| 5017 const dynamic vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[]; |
| 5018 '''); |
| 5019 } |
| 2407 } | 5020 } |
| 2408 | 5021 |
| 2409 test_const_topLevel_typedList_imported() { | 5022 test_const_topLevel_typedList_imported() { |
| 2410 addLibrarySource('/a.dart', 'class C {}'); | 5023 addLibrarySource('/a.dart', 'class C {}'); |
| 2411 checkLibrary(r''' | 5024 var library = checkLibrary(r''' |
| 2412 import 'a.dart'; | 5025 import 'a.dart'; |
| 2413 const v = const <C>[]; | 5026 const v = const <C>[]; |
| 2414 '''); | 5027 '''); |
| 5028 if (isStrongMode) { |
| 5029 checkElementText( |
| 5030 library, |
| 5031 r''' |
| 5032 import 'a.dart'; |
| 5033 const List<C> v = const <C>[]; |
| 5034 '''); |
| 5035 } else { |
| 5036 checkElementText( |
| 5037 library, |
| 5038 r''' |
| 5039 import 'a.dart'; |
| 5040 const dynamic v = const <C>[]; |
| 5041 '''); |
| 5042 } |
| 2415 } | 5043 } |
| 2416 | 5044 |
| 2417 test_const_topLevel_typedList_importedWithPrefix() { | 5045 test_const_topLevel_typedList_importedWithPrefix() { |
| 2418 addLibrarySource('/a.dart', 'class C {}'); | 5046 addLibrarySource('/a.dart', 'class C {}'); |
| 2419 checkLibrary(r''' | 5047 var library = checkLibrary(r''' |
| 2420 import 'a.dart' as p; | 5048 import 'a.dart' as p; |
| 2421 const v = const <p.C>[]; | 5049 const v = const <p.C>[]; |
| 2422 '''); | 5050 '''); |
| 5051 if (isStrongMode) { |
| 5052 checkElementText( |
| 5053 library, |
| 5054 r''' |
| 5055 import 'a.dart' as p; |
| 5056 const List<C> v = const <C>[]; |
| 5057 '''); |
| 5058 } else { |
| 5059 checkElementText( |
| 5060 library, |
| 5061 r''' |
| 5062 import 'a.dart' as p; |
| 5063 const dynamic v = const <C>[]; |
| 5064 '''); |
| 5065 } |
| 2423 } | 5066 } |
| 2424 | 5067 |
| 2425 test_const_topLevel_typedMap() { | 5068 test_const_topLevel_typedMap() { |
| 2426 checkLibrary(r''' | 5069 var library = checkLibrary(r''' |
| 2427 const vDynamic1 = const <dynamic, int>{}; | 5070 const vDynamic1 = const <dynamic, int>{}; |
| 2428 const vDynamic2 = const <int, dynamic>{}; | 5071 const vDynamic2 = const <int, dynamic>{}; |
| 2429 const vInterface = const <int, String>{}; | 5072 const vInterface = const <int, String>{}; |
| 2430 const vInterfaceWithTypeArguments = const <int, List<String>>{}; | 5073 const vInterfaceWithTypeArguments = const <int, List<String>>{}; |
| 2431 '''); | 5074 '''); |
| 5075 if (isStrongMode) { |
| 5076 checkElementText( |
| 5077 library, |
| 5078 r''' |
| 5079 const Map<dynamic, int> vDynamic1 = const <dynamic, int>{}; |
| 5080 const Map<int, dynamic> vDynamic2 = const <int, dynamic>{}; |
| 5081 const Map<int, String> vInterface = const <int, String>{}; |
| 5082 const Map<int, List<String>> vInterfaceWithTypeArguments = const <int, List<Stri
ng>>{}; |
| 5083 '''); |
| 5084 } else { |
| 5085 checkElementText( |
| 5086 library, |
| 5087 r''' |
| 5088 const dynamic vDynamic1 = const <dynamic, int>{}; |
| 5089 const dynamic vDynamic2 = const <int, dynamic>{}; |
| 5090 const dynamic vInterface = const <int, String>{}; |
| 5091 const dynamic vInterfaceWithTypeArguments = const <int, List<String>>{}; |
| 5092 '''); |
| 5093 } |
| 2432 } | 5094 } |
| 2433 | 5095 |
| 2434 test_const_topLevel_untypedList() { | 5096 test_const_topLevel_untypedList() { |
| 2435 checkLibrary(r''' | 5097 var library = checkLibrary(r''' |
| 2436 const v = const [1, 2, 3]; | 5098 const v = const [1, 2, 3]; |
| 2437 '''); | 5099 '''); |
| 5100 if (isStrongMode) { |
| 5101 checkElementText( |
| 5102 library, |
| 5103 r''' |
| 5104 const List<int> v = const [1, 2, 3]; |
| 5105 '''); |
| 5106 } else { |
| 5107 checkElementText( |
| 5108 library, |
| 5109 r''' |
| 5110 const dynamic v = const [1, 2, 3]; |
| 5111 '''); |
| 5112 } |
| 2438 } | 5113 } |
| 2439 | 5114 |
| 2440 test_const_topLevel_untypedMap() { | 5115 test_const_topLevel_untypedMap() { |
| 2441 checkLibrary(r''' | 5116 var library = checkLibrary(r''' |
| 2442 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; | 5117 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; |
| 2443 '''); | 5118 '''); |
| 5119 if (isStrongMode) { |
| 5120 checkElementText( |
| 5121 library, |
| 5122 r''' |
| 5123 const Map<int, String> v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; |
| 5124 '''); |
| 5125 } else { |
| 5126 checkElementText( |
| 5127 library, |
| 5128 r''' |
| 5129 const dynamic v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; |
| 5130 '''); |
| 5131 } |
| 2444 } | 5132 } |
| 2445 | 5133 |
| 2446 test_constExpr_pushReference_field_simpleIdentifier() { | 5134 test_constExpr_pushReference_field_simpleIdentifier() { |
| 2447 checkLibrary(''' | 5135 var library = checkLibrary(''' |
| 2448 class C { | 5136 class C { |
| 2449 static const a = b; | 5137 static const a = b; |
| 2450 static const b = null; | 5138 static const b = null; |
| 2451 } | 5139 } |
| 2452 '''); | 5140 '''); |
| 5141 if (isStrongMode) { |
| 5142 checkElementText( |
| 5143 library, |
| 5144 r''' |
| 5145 class C { |
| 5146 static const dynamic a = C.b; |
| 5147 static const dynamic b = null; |
| 5148 } |
| 5149 '''); |
| 5150 } else { |
| 5151 checkElementText( |
| 5152 library, |
| 5153 r''' |
| 5154 class C { |
| 5155 static const dynamic a = C.b; |
| 5156 static const dynamic b = null; |
| 5157 } |
| 5158 '''); |
| 5159 } |
| 2453 } | 5160 } |
| 2454 | 5161 |
| 2455 test_constExpr_pushReference_staticMethod_simpleIdentifier() { | 5162 test_constExpr_pushReference_staticMethod_simpleIdentifier() { |
| 2456 checkLibrary(''' | 5163 var library = checkLibrary(''' |
| 2457 class C { | 5164 class C { |
| 2458 static const a = m; | 5165 static const a = m; |
| 2459 static m() {} | 5166 static m() {} |
| 2460 } | 5167 } |
| 2461 '''); | 5168 '''); |
| 5169 if (isStrongMode) { |
| 5170 checkElementText( |
| 5171 library, |
| 5172 r''' |
| 5173 class C { |
| 5174 static const () → dynamic a = C.m; |
| 5175 static dynamic m() {} |
| 5176 } |
| 5177 '''); |
| 5178 } else { |
| 5179 checkElementText( |
| 5180 library, |
| 5181 r''' |
| 5182 class C { |
| 5183 static const dynamic a = C.m; |
| 5184 static dynamic m() {} |
| 5185 } |
| 5186 '''); |
| 5187 } |
| 2462 } | 5188 } |
| 2463 | 5189 |
| 2464 test_constructor_documented() { | 5190 test_constructor_documented() { |
| 2465 checkLibrary(''' | 5191 var library = checkLibrary(''' |
| 2466 class C { | 5192 class C { |
| 2467 /** | 5193 /** |
| 2468 * Docs | 5194 * Docs |
| 2469 */ | 5195 */ |
| 2470 C(); | 5196 C(); |
| 2471 }'''); | 5197 }'''); |
| 5198 if (isStrongMode) { |
| 5199 checkElementText( |
| 5200 library, |
| 5201 r''' |
| 5202 class C { |
| 5203 /** |
| 5204 * Docs |
| 5205 */ |
| 5206 C(); |
| 5207 } |
| 5208 '''); |
| 5209 } else { |
| 5210 checkElementText( |
| 5211 library, |
| 5212 r''' |
| 5213 class C { |
| 5214 /** |
| 5215 * Docs |
| 5216 */ |
| 5217 C(); |
| 5218 } |
| 5219 '''); |
| 5220 } |
| 2472 } | 5221 } |
| 2473 | 5222 |
| 2474 test_constructor_initializers_assertInvocation() { | 5223 test_constructor_initializers_assertInvocation() { |
| 2475 checkLibrary(''' | 5224 var library = checkLibrary(''' |
| 2476 class C { | 5225 class C { |
| 2477 const C(int x) : assert(x >= 42); | 5226 const C(int x) : assert(x >= 42); |
| 2478 } | 5227 } |
| 2479 '''); | 5228 '''); |
| 5229 if (isStrongMode) { |
| 5230 checkElementText( |
| 5231 library, |
| 5232 r''' |
| 5233 class C { |
| 5234 const C(int x) : assert(x >= 42); |
| 5235 } |
| 5236 '''); |
| 5237 } else { |
| 5238 checkElementText( |
| 5239 library, |
| 5240 r''' |
| 5241 class C { |
| 5242 const C(int x) : assert(x >= 42); |
| 5243 } |
| 5244 '''); |
| 5245 } |
| 2480 } | 5246 } |
| 2481 | 5247 |
| 2482 test_constructor_initializers_assertInvocation_message() { | 5248 test_constructor_initializers_assertInvocation_message() { |
| 2483 checkLibrary(''' | 5249 var library = checkLibrary(''' |
| 2484 class C { | 5250 class C { |
| 2485 const C(int x) : assert(x >= 42, 'foo'); | 5251 const C(int x) : assert(x >= 42, 'foo'); |
| 2486 } | 5252 } |
| 2487 '''); | 5253 '''); |
| 5254 if (isStrongMode) { |
| 5255 checkElementText( |
| 5256 library, |
| 5257 r''' |
| 5258 class C { |
| 5259 const C(int x) : assert(x >= 42, 'foo'); |
| 5260 } |
| 5261 '''); |
| 5262 } else { |
| 5263 checkElementText( |
| 5264 library, |
| 5265 r''' |
| 5266 class C { |
| 5267 const C(int x) : assert(x >= 42, 'foo'); |
| 5268 } |
| 5269 '''); |
| 5270 } |
| 2488 } | 5271 } |
| 2489 | 5272 |
| 2490 test_constructor_initializers_field() { | 5273 test_constructor_initializers_field() { |
| 2491 checkLibrary(''' | 5274 var library = checkLibrary(''' |
| 2492 class C { | 5275 class C { |
| 2493 final x; | 5276 final x; |
| 2494 const C() : x = 42; | 5277 const C() : x = 42; |
| 2495 } | 5278 } |
| 2496 '''); | 5279 '''); |
| 5280 if (isStrongMode) { |
| 5281 checkElementText( |
| 5282 library, |
| 5283 r''' |
| 5284 class C { |
| 5285 final dynamic x; |
| 5286 const C() : x = 42; |
| 5287 } |
| 5288 '''); |
| 5289 } else { |
| 5290 checkElementText( |
| 5291 library, |
| 5292 r''' |
| 5293 class C { |
| 5294 final dynamic x; |
| 5295 const C() : x = 42; |
| 5296 } |
| 5297 '''); |
| 5298 } |
| 2497 } | 5299 } |
| 2498 | 5300 |
| 2499 test_constructor_initializers_field_notConst() { | 5301 test_constructor_initializers_field_notConst() { |
| 2500 variablesWithNotConstInitializers.add('x'); | 5302 variablesWithNotConstInitializers.add('x'); |
| 2501 checkLibrary( | 5303 var library = checkLibrary( |
| 2502 ''' | 5304 ''' |
| 2503 class C { | 5305 class C { |
| 2504 final x; | 5306 final x; |
| 2505 const A() : x = foo(); | 5307 const A() : x = foo(); |
| 2506 } | 5308 } |
| 2507 int foo() => 42; | 5309 int foo() => 42; |
| 2508 ''', | 5310 ''', |
| 2509 allowErrors: true); | 5311 allowErrors: true); |
| 5312 if (isStrongMode) { |
| 5313 checkElementText( |
| 5314 library, |
| 5315 r''' |
| 5316 class C { |
| 5317 final dynamic x; |
| 5318 const C() : x = $$invalidConstExpr$$; |
| 5319 } |
| 5320 int foo() {} |
| 5321 '''); |
| 5322 } else { |
| 5323 checkElementText( |
| 5324 library, |
| 5325 r''' |
| 5326 class C { |
| 5327 final dynamic x; |
| 5328 const C() : x = $$invalidConstExpr$$; |
| 5329 } |
| 5330 int foo() {} |
| 5331 '''); |
| 5332 } |
| 2510 } | 5333 } |
| 2511 | 5334 |
| 2512 test_constructor_initializers_field_withParameter() { | 5335 test_constructor_initializers_field_withParameter() { |
| 2513 checkLibrary(''' | 5336 var library = checkLibrary(''' |
| 2514 class C { | 5337 class C { |
| 2515 final x; | 5338 final x; |
| 2516 const C(int p) : x = 1 + p; | 5339 const C(int p) : x = 1 + p; |
| 2517 } | 5340 } |
| 2518 '''); | 5341 '''); |
| 5342 if (isStrongMode) { |
| 5343 checkElementText( |
| 5344 library, |
| 5345 r''' |
| 5346 class C { |
| 5347 final dynamic x; |
| 5348 const C(int p) : x = 1 + p; |
| 5349 } |
| 5350 '''); |
| 5351 } else { |
| 5352 checkElementText( |
| 5353 library, |
| 5354 r''' |
| 5355 class C { |
| 5356 final dynamic x; |
| 5357 const C(int p) : x = 1 + p; |
| 5358 } |
| 5359 '''); |
| 5360 } |
| 2519 } | 5361 } |
| 2520 | 5362 |
| 2521 test_constructor_initializers_superInvocation_named() { | 5363 test_constructor_initializers_superInvocation_named() { |
| 2522 checkLibrary(''' | 5364 var library = checkLibrary(''' |
| 2523 class A { | 5365 class A { |
| 2524 const A.aaa(int p); | 5366 const A.aaa(int p); |
| 2525 } | 5367 } |
| 5368 class C extends A { |
| 5369 const C() : super.aaa(42); |
| 5370 } |
| 5371 '''); |
| 5372 if (isStrongMode) { |
| 5373 checkElementText( |
| 5374 library, |
| 5375 r''' |
| 5376 class A { |
| 5377 const A.aaa(int p); |
| 5378 } |
| 5379 class C extends A { |
| 5380 const C() : super.aaa(42); |
| 5381 } |
| 5382 '''); |
| 5383 } else { |
| 5384 checkElementText( |
| 5385 library, |
| 5386 r''' |
| 5387 class A { |
| 5388 const A.aaa(int p); |
| 5389 } |
| 2526 class C extends A { | 5390 class C extends A { |
| 2527 const C() : super.aaa(42); | 5391 const C() : super.aaa(42); |
| 2528 } | 5392 } |
| 2529 '''); | 5393 '''); |
| 5394 } |
| 2530 } | 5395 } |
| 2531 | 5396 |
| 2532 test_constructor_initializers_superInvocation_namedExpression() { | 5397 test_constructor_initializers_superInvocation_namedExpression() { |
| 2533 checkLibrary(''' | 5398 var library = checkLibrary(''' |
| 2534 class A { | 5399 class A { |
| 2535 const A.aaa(a, {int b}); | 5400 const A.aaa(a, {int b}); |
| 2536 } | 5401 } |
| 2537 class C extends A { | 5402 class C extends A { |
| 2538 const C() : super.aaa(1, b: 2); | 5403 const C() : super.aaa(1, b: 2); |
| 2539 } | 5404 } |
| 2540 '''); | 5405 '''); |
| 5406 if (isStrongMode) { |
| 5407 checkElementText( |
| 5408 library, |
| 5409 r''' |
| 5410 class A { |
| 5411 const A.aaa(dynamic a, {int b}); |
| 5412 } |
| 5413 class C extends A { |
| 5414 const C() : super.aaa(1, b: 2); |
| 5415 } |
| 5416 '''); |
| 5417 } else { |
| 5418 checkElementText( |
| 5419 library, |
| 5420 r''' |
| 5421 class A { |
| 5422 const A.aaa(dynamic a, {int b}); |
| 5423 } |
| 5424 class C extends A { |
| 5425 const C() : super.aaa(1, b: 2); |
| 5426 } |
| 5427 '''); |
| 5428 } |
| 2541 } | 5429 } |
| 2542 | 5430 |
| 2543 test_constructor_initializers_superInvocation_unnamed() { | 5431 test_constructor_initializers_superInvocation_unnamed() { |
| 2544 checkLibrary(''' | 5432 var library = checkLibrary(''' |
| 2545 class A { | 5433 class A { |
| 2546 const A(int p); | 5434 const A(int p); |
| 2547 } | 5435 } |
| 5436 class C extends A { |
| 5437 const C.ccc() : super(42); |
| 5438 } |
| 5439 '''); |
| 5440 if (isStrongMode) { |
| 5441 checkElementText( |
| 5442 library, |
| 5443 r''' |
| 5444 class A { |
| 5445 const A(int p); |
| 5446 } |
| 5447 class C extends A { |
| 5448 const C.ccc() : super(42); |
| 5449 } |
| 5450 '''); |
| 5451 } else { |
| 5452 checkElementText( |
| 5453 library, |
| 5454 r''' |
| 5455 class A { |
| 5456 const A(int p); |
| 5457 } |
| 2548 class C extends A { | 5458 class C extends A { |
| 2549 const C.ccc() : super(42); | 5459 const C.ccc() : super(42); |
| 2550 } | 5460 } |
| 2551 '''); | 5461 '''); |
| 5462 } |
| 2552 } | 5463 } |
| 2553 | 5464 |
| 2554 test_constructor_initializers_thisInvocation_named() { | 5465 test_constructor_initializers_thisInvocation_named() { |
| 2555 checkLibrary(''' | 5466 var library = checkLibrary(''' |
| 2556 class C { | 5467 class C { |
| 2557 const C() : this.named(1, 'bbb'); | 5468 const C() : this.named(1, 'bbb'); |
| 2558 const C.named(int a, String b); | 5469 const C.named(int a, String b); |
| 2559 } | 5470 } |
| 2560 '''); | 5471 '''); |
| 5472 if (isStrongMode) { |
| 5473 checkElementText( |
| 5474 library, |
| 5475 r''' |
| 5476 class C { |
| 5477 const C() = C.named : this.named(1, 'bbb'); |
| 5478 const C.named(int a, String b); |
| 5479 } |
| 5480 '''); |
| 5481 } else { |
| 5482 checkElementText( |
| 5483 library, |
| 5484 r''' |
| 5485 class C { |
| 5486 const C() = C.named : this.named(1, 'bbb'); |
| 5487 const C.named(int a, String b); |
| 5488 } |
| 5489 '''); |
| 5490 } |
| 2561 } | 5491 } |
| 2562 | 5492 |
| 2563 test_constructor_initializers_thisInvocation_namedExpression() { | 5493 test_constructor_initializers_thisInvocation_namedExpression() { |
| 2564 checkLibrary(''' | 5494 var library = checkLibrary(''' |
| 2565 class C { | 5495 class C { |
| 2566 const C() : this.named(1, b: 2); | 5496 const C() : this.named(1, b: 2); |
| 2567 const C.named(a, {int b}); | 5497 const C.named(a, {int b}); |
| 2568 } | 5498 } |
| 2569 '''); | 5499 '''); |
| 5500 if (isStrongMode) { |
| 5501 checkElementText( |
| 5502 library, |
| 5503 r''' |
| 5504 class C { |
| 5505 const C() = C.named : this.named(1, b: 2); |
| 5506 const C.named(dynamic a, {int b}); |
| 5507 } |
| 5508 '''); |
| 5509 } else { |
| 5510 checkElementText( |
| 5511 library, |
| 5512 r''' |
| 5513 class C { |
| 5514 const C() = C.named : this.named(1, b: 2); |
| 5515 const C.named(dynamic a, {int b}); |
| 5516 } |
| 5517 '''); |
| 5518 } |
| 2570 } | 5519 } |
| 2571 | 5520 |
| 2572 test_constructor_initializers_thisInvocation_unnamed() { | 5521 test_constructor_initializers_thisInvocation_unnamed() { |
| 2573 checkLibrary(''' | 5522 var library = checkLibrary(''' |
| 2574 class C { | 5523 class C { |
| 2575 const C.named() : this(1, 'bbb'); | 5524 const C.named() : this(1, 'bbb'); |
| 2576 const C(int a, String b); | 5525 const C(int a, String b); |
| 2577 } | 5526 } |
| 2578 '''); | 5527 '''); |
| 5528 if (isStrongMode) { |
| 5529 checkElementText( |
| 5530 library, |
| 5531 r''' |
| 5532 class C { |
| 5533 const C.named() = C : this(1, 'bbb'); |
| 5534 const C(int a, String b); |
| 5535 } |
| 5536 '''); |
| 5537 } else { |
| 5538 checkElementText( |
| 5539 library, |
| 5540 r''' |
| 5541 class C { |
| 5542 const C.named() = C : this(1, 'bbb'); |
| 5543 const C(int a, String b); |
| 5544 } |
| 5545 '''); |
| 5546 } |
| 2579 } | 5547 } |
| 2580 | 5548 |
| 2581 test_constructor_redirected_factory_named() { | 5549 test_constructor_redirected_factory_named() { |
| 2582 checkLibrary(''' | 5550 var library = checkLibrary(''' |
| 2583 class C { | 5551 class C { |
| 2584 factory C() = D.named; | 5552 factory C() = D.named; |
| 2585 C._(); | 5553 C._(); |
| 2586 } | 5554 } |
| 2587 class D extends C { | 5555 class D extends C { |
| 2588 D.named() : super._(); | 5556 D.named() : super._(); |
| 2589 } | 5557 } |
| 2590 '''); | 5558 '''); |
| 5559 if (isStrongMode) { |
| 5560 checkElementText( |
| 5561 library, |
| 5562 r''' |
| 5563 class C { |
| 5564 factory C() = D.named; |
| 5565 C._(); |
| 5566 } |
| 5567 class D extends C { |
| 5568 D.named(); |
| 5569 } |
| 5570 '''); |
| 5571 } else { |
| 5572 checkElementText( |
| 5573 library, |
| 5574 r''' |
| 5575 class C { |
| 5576 factory C() = D.named; |
| 5577 C._(); |
| 5578 } |
| 5579 class D extends C { |
| 5580 D.named(); |
| 5581 } |
| 5582 '''); |
| 5583 } |
| 2591 } | 5584 } |
| 2592 | 5585 |
| 2593 test_constructor_redirected_factory_named_generic() { | 5586 test_constructor_redirected_factory_named_generic() { |
| 2594 checkLibrary(''' | 5587 var library = checkLibrary(''' |
| 2595 class C<T, U> { | 5588 class C<T, U> { |
| 2596 factory C() = D<U, T>.named; | 5589 factory C() = D<U, T>.named; |
| 2597 C._(); | 5590 C._(); |
| 2598 } | 5591 } |
| 2599 class D<T, U> extends C<U, T> { | 5592 class D<T, U> extends C<U, T> { |
| 2600 D.named() : super._(); | 5593 D.named() : super._(); |
| 2601 } | 5594 } |
| 2602 '''); | 5595 '''); |
| 5596 if (isStrongMode) { |
| 5597 checkElementText( |
| 5598 library, |
| 5599 r''' |
| 5600 class C<T, U> { |
| 5601 factory C() = D<U, T>.named; |
| 5602 C._(); |
| 5603 } |
| 5604 class D<T, U> extends C<U, T> { |
| 5605 D.named(); |
| 5606 } |
| 5607 '''); |
| 5608 } else { |
| 5609 checkElementText( |
| 5610 library, |
| 5611 r''' |
| 5612 class C<T, U> { |
| 5613 factory C() = D<U, T>.named; |
| 5614 C._(); |
| 5615 } |
| 5616 class D<T, U> extends C<U, T> { |
| 5617 D.named(); |
| 5618 } |
| 5619 '''); |
| 5620 } |
| 2603 } | 5621 } |
| 2604 | 5622 |
| 2605 test_constructor_redirected_factory_named_imported() { | 5623 test_constructor_redirected_factory_named_imported() { |
| 2606 addLibrarySource( | 5624 addLibrarySource( |
| 2607 '/foo.dart', | 5625 '/foo.dart', |
| 2608 ''' | 5626 ''' |
| 2609 import 'test.dart'; | 5627 import 'test.dart'; |
| 2610 class D extends C { | 5628 class D extends C { |
| 2611 D.named() : super._(); | 5629 D.named() : super._(); |
| 2612 } | 5630 } |
| 2613 '''); | 5631 '''); |
| 2614 checkLibrary(''' | 5632 var library = checkLibrary(''' |
| 2615 import 'foo.dart'; | 5633 import 'foo.dart'; |
| 2616 class C { | 5634 class C { |
| 2617 factory C() = D.named; | 5635 factory C() = D.named; |
| 2618 C._(); | 5636 C._(); |
| 2619 } | 5637 } |
| 2620 '''); | 5638 '''); |
| 5639 if (isStrongMode) { |
| 5640 checkElementText( |
| 5641 library, |
| 5642 r''' |
| 5643 import 'foo.dart'; |
| 5644 class C { |
| 5645 factory C() = D.named; |
| 5646 C._(); |
| 5647 } |
| 5648 '''); |
| 5649 } else { |
| 5650 checkElementText( |
| 5651 library, |
| 5652 r''' |
| 5653 import 'foo.dart'; |
| 5654 class C { |
| 5655 factory C() = D.named; |
| 5656 C._(); |
| 5657 } |
| 5658 '''); |
| 5659 } |
| 2621 } | 5660 } |
| 2622 | 5661 |
| 2623 test_constructor_redirected_factory_named_imported_generic() { | 5662 test_constructor_redirected_factory_named_imported_generic() { |
| 2624 addLibrarySource( | 5663 addLibrarySource( |
| 2625 '/foo.dart', | 5664 '/foo.dart', |
| 2626 ''' | 5665 ''' |
| 2627 import 'test.dart'; | 5666 import 'test.dart'; |
| 2628 class D<T, U> extends C<U, T> { | 5667 class D<T, U> extends C<U, T> { |
| 2629 D.named() : super._(); | 5668 D.named() : super._(); |
| 2630 } | 5669 } |
| 2631 '''); | 5670 '''); |
| 2632 checkLibrary(''' | 5671 var library = checkLibrary(''' |
| 2633 import 'foo.dart'; | 5672 import 'foo.dart'; |
| 2634 class C<T, U> { | 5673 class C<T, U> { |
| 2635 factory C() = D<U, T>.named; | 5674 factory C() = D<U, T>.named; |
| 2636 C._(); | 5675 C._(); |
| 2637 } | 5676 } |
| 2638 '''); | 5677 '''); |
| 5678 if (isStrongMode) { |
| 5679 checkElementText( |
| 5680 library, |
| 5681 r''' |
| 5682 import 'foo.dart'; |
| 5683 class C<T, U> { |
| 5684 factory C() = D<U, T>.named; |
| 5685 C._(); |
| 5686 } |
| 5687 '''); |
| 5688 } else { |
| 5689 checkElementText( |
| 5690 library, |
| 5691 r''' |
| 5692 import 'foo.dart'; |
| 5693 class C<T, U> { |
| 5694 factory C() = D<U, T>.named; |
| 5695 C._(); |
| 5696 } |
| 5697 '''); |
| 5698 } |
| 2639 } | 5699 } |
| 2640 | 5700 |
| 2641 test_constructor_redirected_factory_named_prefixed() { | 5701 test_constructor_redirected_factory_named_prefixed() { |
| 2642 addLibrarySource( | 5702 addLibrarySource( |
| 2643 '/foo.dart', | 5703 '/foo.dart', |
| 2644 ''' | 5704 ''' |
| 2645 import 'test.dart'; | 5705 import 'test.dart'; |
| 2646 class D extends C { | 5706 class D extends C { |
| 2647 D.named() : super._(); | 5707 D.named() : super._(); |
| 2648 } | 5708 } |
| 2649 '''); | 5709 '''); |
| 2650 checkLibrary(''' | 5710 var library = checkLibrary(''' |
| 2651 import 'foo.dart' as foo; | 5711 import 'foo.dart' as foo; |
| 2652 class C { | 5712 class C { |
| 2653 factory C() = foo.D.named; | 5713 factory C() = foo.D.named; |
| 2654 C._(); | 5714 C._(); |
| 2655 } | 5715 } |
| 2656 '''); | 5716 '''); |
| 5717 if (isStrongMode) { |
| 5718 checkElementText( |
| 5719 library, |
| 5720 r''' |
| 5721 import 'foo.dart' as foo; |
| 5722 class C { |
| 5723 factory C() = D.named; |
| 5724 C._(); |
| 5725 } |
| 5726 '''); |
| 5727 } else { |
| 5728 checkElementText( |
| 5729 library, |
| 5730 r''' |
| 5731 import 'foo.dart' as foo; |
| 5732 class C { |
| 5733 factory C() = D.named; |
| 5734 C._(); |
| 5735 } |
| 5736 '''); |
| 5737 } |
| 2657 } | 5738 } |
| 2658 | 5739 |
| 2659 test_constructor_redirected_factory_named_prefixed_generic() { | 5740 test_constructor_redirected_factory_named_prefixed_generic() { |
| 2660 addLibrarySource( | 5741 addLibrarySource( |
| 2661 '/foo.dart', | 5742 '/foo.dart', |
| 2662 ''' | 5743 ''' |
| 2663 import 'test.dart'; | 5744 import 'test.dart'; |
| 2664 class D<T, U> extends C<U, T> { | 5745 class D<T, U> extends C<U, T> { |
| 2665 D.named() : super._(); | 5746 D.named() : super._(); |
| 2666 } | 5747 } |
| 2667 '''); | 5748 '''); |
| 2668 checkLibrary(''' | 5749 var library = checkLibrary(''' |
| 2669 import 'foo.dart' as foo; | 5750 import 'foo.dart' as foo; |
| 2670 class C<T, U> { | 5751 class C<T, U> { |
| 2671 factory C() = foo.D<U, T>.named; | 5752 factory C() = foo.D<U, T>.named; |
| 2672 C._(); | 5753 C._(); |
| 2673 } | 5754 } |
| 2674 '''); | 5755 '''); |
| 5756 if (isStrongMode) { |
| 5757 checkElementText( |
| 5758 library, |
| 5759 r''' |
| 5760 import 'foo.dart' as foo; |
| 5761 class C<T, U> { |
| 5762 factory C() = D<U, T>.named; |
| 5763 C._(); |
| 5764 } |
| 5765 '''); |
| 5766 } else { |
| 5767 checkElementText( |
| 5768 library, |
| 5769 r''' |
| 5770 import 'foo.dart' as foo; |
| 5771 class C<T, U> { |
| 5772 factory C() = D<U, T>.named; |
| 5773 C._(); |
| 5774 } |
| 5775 '''); |
| 5776 } |
| 2675 } | 5777 } |
| 2676 | 5778 |
| 2677 test_constructor_redirected_factory_named_unresolved_class() { | 5779 test_constructor_redirected_factory_named_unresolved_class() { |
| 2678 checkLibrary( | 5780 var library = checkLibrary( |
| 2679 ''' | 5781 ''' |
| 2680 class C<E> { | 5782 class C<E> { |
| 2681 factory C() = D.named<E>; | 5783 factory C() = D.named<E>; |
| 2682 } | 5784 } |
| 2683 ''', | 5785 ''', |
| 2684 allowErrors: true); | 5786 allowErrors: true); |
| 5787 if (isStrongMode) { |
| 5788 checkElementText( |
| 5789 library, |
| 5790 r''' |
| 5791 class C<E> { |
| 5792 factory C(); |
| 5793 } |
| 5794 '''); |
| 5795 } else { |
| 5796 checkElementText( |
| 5797 library, |
| 5798 r''' |
| 5799 class C<E> { |
| 5800 factory C(); |
| 5801 } |
| 5802 '''); |
| 5803 } |
| 2685 } | 5804 } |
| 2686 | 5805 |
| 2687 test_constructor_redirected_factory_named_unresolved_constructor() { | 5806 test_constructor_redirected_factory_named_unresolved_constructor() { |
| 2688 checkLibrary( | 5807 var library = checkLibrary( |
| 2689 ''' | 5808 ''' |
| 2690 class D {} | 5809 class D {} |
| 2691 class C<E> { | 5810 class C<E> { |
| 2692 factory C() = D.named<E>; | 5811 factory C() = D.named<E>; |
| 2693 } | 5812 } |
| 2694 ''', | 5813 ''', |
| 2695 allowErrors: true); | 5814 allowErrors: true); |
| 5815 if (isStrongMode) { |
| 5816 checkElementText( |
| 5817 library, |
| 5818 r''' |
| 5819 class D { |
| 5820 } |
| 5821 class C<E> { |
| 5822 factory C(); |
| 5823 } |
| 5824 '''); |
| 5825 } else { |
| 5826 checkElementText( |
| 5827 library, |
| 5828 r''' |
| 5829 class D { |
| 5830 } |
| 5831 class C<E> { |
| 5832 factory C(); |
| 5833 } |
| 5834 '''); |
| 5835 } |
| 2696 } | 5836 } |
| 2697 | 5837 |
| 2698 test_constructor_redirected_factory_unnamed() { | 5838 test_constructor_redirected_factory_unnamed() { |
| 2699 checkLibrary(''' | 5839 var library = checkLibrary(''' |
| 2700 class C { | 5840 class C { |
| 2701 factory C() = D; | 5841 factory C() = D; |
| 2702 C._(); | 5842 C._(); |
| 2703 } | 5843 } |
| 2704 class D extends C { | 5844 class D extends C { |
| 2705 D() : super._(); | 5845 D() : super._(); |
| 2706 } | 5846 } |
| 2707 '''); | 5847 '''); |
| 5848 if (isStrongMode) { |
| 5849 checkElementText( |
| 5850 library, |
| 5851 r''' |
| 5852 class C { |
| 5853 factory C() = D; |
| 5854 C._(); |
| 5855 } |
| 5856 class D extends C { |
| 5857 D(); |
| 5858 } |
| 5859 '''); |
| 5860 } else { |
| 5861 checkElementText( |
| 5862 library, |
| 5863 r''' |
| 5864 class C { |
| 5865 factory C() = D; |
| 5866 C._(); |
| 5867 } |
| 5868 class D extends C { |
| 5869 D(); |
| 5870 } |
| 5871 '''); |
| 5872 } |
| 2708 } | 5873 } |
| 2709 | 5874 |
| 2710 test_constructor_redirected_factory_unnamed_generic() { | 5875 test_constructor_redirected_factory_unnamed_generic() { |
| 2711 checkLibrary(''' | 5876 var library = checkLibrary(''' |
| 2712 class C<T, U> { | 5877 class C<T, U> { |
| 2713 factory C() = D<U, T>; | 5878 factory C() = D<U, T>; |
| 2714 C._(); | 5879 C._(); |
| 2715 } | 5880 } |
| 2716 class D<T, U> extends C<U, T> { | 5881 class D<T, U> extends C<U, T> { |
| 2717 D() : super._(); | 5882 D() : super._(); |
| 2718 } | 5883 } |
| 2719 '''); | 5884 '''); |
| 5885 if (isStrongMode) { |
| 5886 checkElementText( |
| 5887 library, |
| 5888 r''' |
| 5889 class C<T, U> { |
| 5890 factory C() = D<U, T>; |
| 5891 C._(); |
| 5892 } |
| 5893 class D<T, U> extends C<U, T> { |
| 5894 D(); |
| 5895 } |
| 5896 '''); |
| 5897 } else { |
| 5898 checkElementText( |
| 5899 library, |
| 5900 r''' |
| 5901 class C<T, U> { |
| 5902 factory C() = D<U, T>; |
| 5903 C._(); |
| 5904 } |
| 5905 class D<T, U> extends C<U, T> { |
| 5906 D(); |
| 5907 } |
| 5908 '''); |
| 5909 } |
| 2720 } | 5910 } |
| 2721 | 5911 |
| 2722 test_constructor_redirected_factory_unnamed_imported() { | 5912 test_constructor_redirected_factory_unnamed_imported() { |
| 2723 addLibrarySource( | 5913 addLibrarySource( |
| 2724 '/foo.dart', | 5914 '/foo.dart', |
| 2725 ''' | 5915 ''' |
| 2726 import 'test.dart'; | 5916 import 'test.dart'; |
| 2727 class D extends C { | 5917 class D extends C { |
| 2728 D() : super._(); | 5918 D() : super._(); |
| 2729 } | 5919 } |
| 2730 '''); | 5920 '''); |
| 2731 checkLibrary(''' | 5921 var library = checkLibrary(''' |
| 2732 import 'foo.dart'; | 5922 import 'foo.dart'; |
| 2733 class C { | 5923 class C { |
| 2734 factory C() = D; | 5924 factory C() = D; |
| 2735 C._(); | 5925 C._(); |
| 2736 } | 5926 } |
| 2737 '''); | 5927 '''); |
| 5928 if (isStrongMode) { |
| 5929 checkElementText( |
| 5930 library, |
| 5931 r''' |
| 5932 import 'foo.dart'; |
| 5933 class C { |
| 5934 factory C() = D; |
| 5935 C._(); |
| 5936 } |
| 5937 '''); |
| 5938 } else { |
| 5939 checkElementText( |
| 5940 library, |
| 5941 r''' |
| 5942 import 'foo.dart'; |
| 5943 class C { |
| 5944 factory C() = D; |
| 5945 C._(); |
| 5946 } |
| 5947 '''); |
| 5948 } |
| 2738 } | 5949 } |
| 2739 | 5950 |
| 2740 test_constructor_redirected_factory_unnamed_imported_generic() { | 5951 test_constructor_redirected_factory_unnamed_imported_generic() { |
| 2741 addLibrarySource( | 5952 addLibrarySource( |
| 2742 '/foo.dart', | 5953 '/foo.dart', |
| 2743 ''' | 5954 ''' |
| 2744 import 'test.dart'; | 5955 import 'test.dart'; |
| 2745 class D<T, U> extends C<U, T> { | 5956 class D<T, U> extends C<U, T> { |
| 2746 D() : super._(); | 5957 D() : super._(); |
| 2747 } | 5958 } |
| 2748 '''); | 5959 '''); |
| 2749 checkLibrary(''' | 5960 var library = checkLibrary(''' |
| 2750 import 'foo.dart'; | 5961 import 'foo.dart'; |
| 2751 class C<T, U> { | 5962 class C<T, U> { |
| 2752 factory C() = D<U, T>; | 5963 factory C() = D<U, T>; |
| 2753 C._(); | 5964 C._(); |
| 2754 } | 5965 } |
| 2755 '''); | 5966 '''); |
| 5967 if (isStrongMode) { |
| 5968 checkElementText( |
| 5969 library, |
| 5970 r''' |
| 5971 import 'foo.dart'; |
| 5972 class C<T, U> { |
| 5973 factory C() = D<U, T>; |
| 5974 C._(); |
| 5975 } |
| 5976 '''); |
| 5977 } else { |
| 5978 checkElementText( |
| 5979 library, |
| 5980 r''' |
| 5981 import 'foo.dart'; |
| 5982 class C<T, U> { |
| 5983 factory C() = D<U, T>; |
| 5984 C._(); |
| 5985 } |
| 5986 '''); |
| 5987 } |
| 2756 } | 5988 } |
| 2757 | 5989 |
| 2758 test_constructor_redirected_factory_unnamed_prefixed() { | 5990 test_constructor_redirected_factory_unnamed_prefixed() { |
| 2759 addLibrarySource( | 5991 addLibrarySource( |
| 2760 '/foo.dart', | 5992 '/foo.dart', |
| 2761 ''' | 5993 ''' |
| 2762 import 'test.dart'; | 5994 import 'test.dart'; |
| 2763 class D extends C { | 5995 class D extends C { |
| 2764 D() : super._(); | 5996 D() : super._(); |
| 2765 } | 5997 } |
| 2766 '''); | 5998 '''); |
| 2767 checkLibrary(''' | 5999 var library = checkLibrary(''' |
| 2768 import 'foo.dart' as foo; | 6000 import 'foo.dart' as foo; |
| 2769 class C { | 6001 class C { |
| 2770 factory C() = foo.D; | 6002 factory C() = foo.D; |
| 2771 C._(); | 6003 C._(); |
| 2772 } | 6004 } |
| 2773 '''); | 6005 '''); |
| 6006 if (isStrongMode) { |
| 6007 checkElementText( |
| 6008 library, |
| 6009 r''' |
| 6010 import 'foo.dart' as foo; |
| 6011 class C { |
| 6012 factory C() = D; |
| 6013 C._(); |
| 6014 } |
| 6015 '''); |
| 6016 } else { |
| 6017 checkElementText( |
| 6018 library, |
| 6019 r''' |
| 6020 import 'foo.dart' as foo; |
| 6021 class C { |
| 6022 factory C() = D; |
| 6023 C._(); |
| 6024 } |
| 6025 '''); |
| 6026 } |
| 2774 } | 6027 } |
| 2775 | 6028 |
| 2776 test_constructor_redirected_factory_unnamed_prefixed_generic() { | 6029 test_constructor_redirected_factory_unnamed_prefixed_generic() { |
| 2777 addLibrarySource( | 6030 addLibrarySource( |
| 2778 '/foo.dart', | 6031 '/foo.dart', |
| 2779 ''' | 6032 ''' |
| 2780 import 'test.dart'; | 6033 import 'test.dart'; |
| 2781 class D<T, U> extends C<U, T> { | 6034 class D<T, U> extends C<U, T> { |
| 2782 D() : super._(); | 6035 D() : super._(); |
| 2783 } | 6036 } |
| 2784 '''); | 6037 '''); |
| 2785 checkLibrary(''' | 6038 var library = checkLibrary(''' |
| 2786 import 'foo.dart' as foo; | 6039 import 'foo.dart' as foo; |
| 2787 class C<T, U> { | 6040 class C<T, U> { |
| 2788 factory C() = foo.D<U, T>; | 6041 factory C() = foo.D<U, T>; |
| 2789 C._(); | 6042 C._(); |
| 2790 } | 6043 } |
| 2791 '''); | 6044 '''); |
| 6045 if (isStrongMode) { |
| 6046 checkElementText( |
| 6047 library, |
| 6048 r''' |
| 6049 import 'foo.dart' as foo; |
| 6050 class C<T, U> { |
| 6051 factory C() = D<U, T>; |
| 6052 C._(); |
| 6053 } |
| 6054 '''); |
| 6055 } else { |
| 6056 checkElementText( |
| 6057 library, |
| 6058 r''' |
| 6059 import 'foo.dart' as foo; |
| 6060 class C<T, U> { |
| 6061 factory C() = D<U, T>; |
| 6062 C._(); |
| 6063 } |
| 6064 '''); |
| 6065 } |
| 2792 } | 6066 } |
| 2793 | 6067 |
| 2794 test_constructor_redirected_factory_unnamed_unresolved() { | 6068 test_constructor_redirected_factory_unnamed_unresolved() { |
| 2795 checkLibrary( | 6069 var library = checkLibrary( |
| 2796 ''' | 6070 ''' |
| 2797 class C<E> { | 6071 class C<E> { |
| 2798 factory C() = D<E>; | 6072 factory C() = D<E>; |
| 2799 } | 6073 } |
| 2800 ''', | 6074 ''', |
| 2801 allowErrors: true); | 6075 allowErrors: true); |
| 6076 if (isStrongMode) { |
| 6077 checkElementText( |
| 6078 library, |
| 6079 r''' |
| 6080 class C<E> { |
| 6081 factory C(); |
| 6082 } |
| 6083 '''); |
| 6084 } else { |
| 6085 checkElementText( |
| 6086 library, |
| 6087 r''' |
| 6088 class C<E> { |
| 6089 factory C(); |
| 6090 } |
| 6091 '''); |
| 6092 } |
| 2802 } | 6093 } |
| 2803 | 6094 |
| 2804 test_constructor_redirected_thisInvocation_named() { | 6095 test_constructor_redirected_thisInvocation_named() { |
| 2805 checkLibrary(''' | 6096 var library = checkLibrary(''' |
| 2806 class C { | 6097 class C { |
| 2807 C.named(); | 6098 C.named(); |
| 2808 C() : this.named(); | 6099 C() : this.named(); |
| 2809 } | 6100 } |
| 2810 '''); | 6101 '''); |
| 6102 if (isStrongMode) { |
| 6103 checkElementText( |
| 6104 library, |
| 6105 r''' |
| 6106 class C { |
| 6107 C.named(); |
| 6108 C() = C.named; |
| 6109 } |
| 6110 '''); |
| 6111 } else { |
| 6112 checkElementText( |
| 6113 library, |
| 6114 r''' |
| 6115 class C { |
| 6116 C.named(); |
| 6117 C() = C.named; |
| 6118 } |
| 6119 '''); |
| 6120 } |
| 2811 } | 6121 } |
| 2812 | 6122 |
| 2813 test_constructor_redirected_thisInvocation_named_generic() { | 6123 test_constructor_redirected_thisInvocation_named_generic() { |
| 2814 checkLibrary(''' | 6124 var library = checkLibrary(''' |
| 2815 class C<T> { | 6125 class C<T> { |
| 2816 C.named(); | 6126 C.named(); |
| 2817 C() : this.named(); | 6127 C() : this.named(); |
| 2818 } | 6128 } |
| 2819 '''); | 6129 '''); |
| 6130 if (isStrongMode) { |
| 6131 checkElementText( |
| 6132 library, |
| 6133 r''' |
| 6134 class C<T> { |
| 6135 C.named(); |
| 6136 C() = C<T>.named; |
| 6137 } |
| 6138 '''); |
| 6139 } else { |
| 6140 checkElementText( |
| 6141 library, |
| 6142 r''' |
| 6143 class C<T> { |
| 6144 C.named(); |
| 6145 C() = C<T>.named; |
| 6146 } |
| 6147 '''); |
| 6148 } |
| 2820 } | 6149 } |
| 2821 | 6150 |
| 2822 test_constructor_redirected_thisInvocation_unnamed() { | 6151 test_constructor_redirected_thisInvocation_unnamed() { |
| 2823 checkLibrary(''' | 6152 var library = checkLibrary(''' |
| 2824 class C { | 6153 class C { |
| 2825 C(); | 6154 C(); |
| 2826 C.named() : this(); | 6155 C.named() : this(); |
| 2827 } | 6156 } |
| 2828 '''); | 6157 '''); |
| 6158 if (isStrongMode) { |
| 6159 checkElementText( |
| 6160 library, |
| 6161 r''' |
| 6162 class C { |
| 6163 C(); |
| 6164 C.named() = C; |
| 6165 } |
| 6166 '''); |
| 6167 } else { |
| 6168 checkElementText( |
| 6169 library, |
| 6170 r''' |
| 6171 class C { |
| 6172 C(); |
| 6173 C.named() = C; |
| 6174 } |
| 6175 '''); |
| 6176 } |
| 2829 } | 6177 } |
| 2830 | 6178 |
| 2831 test_constructor_redirected_thisInvocation_unnamed_generic() { | 6179 test_constructor_redirected_thisInvocation_unnamed_generic() { |
| 2832 checkLibrary(''' | 6180 var library = checkLibrary(''' |
| 2833 class C<T> { | 6181 class C<T> { |
| 2834 C(); | 6182 C(); |
| 2835 C.named() : this(); | 6183 C.named() : this(); |
| 2836 } | 6184 } |
| 2837 '''); | 6185 '''); |
| 6186 if (isStrongMode) { |
| 6187 checkElementText( |
| 6188 library, |
| 6189 r''' |
| 6190 class C<T> { |
| 6191 C(); |
| 6192 C.named() = C<T>; |
| 6193 } |
| 6194 '''); |
| 6195 } else { |
| 6196 checkElementText( |
| 6197 library, |
| 6198 r''' |
| 6199 class C<T> { |
| 6200 C(); |
| 6201 C.named() = C<T>; |
| 6202 } |
| 6203 '''); |
| 6204 } |
| 2838 } | 6205 } |
| 2839 | 6206 |
| 2840 test_constructor_withCycles_const() { | 6207 test_constructor_withCycles_const() { |
| 2841 checkLibrary(''' | 6208 var library = checkLibrary(''' |
| 2842 class C { | 6209 class C { |
| 2843 final x; | 6210 final x; |
| 2844 const C() : x = const D(); | 6211 const C() : x = const D(); |
| 2845 } | 6212 } |
| 2846 class D { | 6213 class D { |
| 2847 final x; | 6214 final x; |
| 2848 const D() : x = const C(); | 6215 const D() : x = const C(); |
| 2849 } | 6216 } |
| 2850 '''); | 6217 '''); |
| 6218 if (isStrongMode) { |
| 6219 checkElementText( |
| 6220 library, |
| 6221 r''' |
| 6222 class C { |
| 6223 final dynamic x; |
| 6224 const C() : x = const D(); |
| 6225 } |
| 6226 class D { |
| 6227 final dynamic x; |
| 6228 const D() : x = const C(); |
| 6229 } |
| 6230 '''); |
| 6231 } else { |
| 6232 checkElementText( |
| 6233 library, |
| 6234 r''' |
| 6235 class C { |
| 6236 final dynamic x; |
| 6237 const C() : x = const D(); |
| 6238 } |
| 6239 class D { |
| 6240 final dynamic x; |
| 6241 const D() : x = const C(); |
| 6242 } |
| 6243 '''); |
| 6244 } |
| 2851 } | 6245 } |
| 2852 | 6246 |
| 2853 test_constructor_withCycles_nonConst() { | 6247 test_constructor_withCycles_nonConst() { |
| 2854 checkLibrary(''' | 6248 var library = checkLibrary(''' |
| 2855 class C { | 6249 class C { |
| 2856 final x; | 6250 final x; |
| 2857 C() : x = new D(); | 6251 C() : x = new D(); |
| 2858 } | 6252 } |
| 2859 class D { | 6253 class D { |
| 2860 final x; | 6254 final x; |
| 2861 D() : x = new C(); | 6255 D() : x = new C(); |
| 2862 } | 6256 } |
| 2863 '''); | 6257 '''); |
| 6258 if (isStrongMode) { |
| 6259 checkElementText( |
| 6260 library, |
| 6261 r''' |
| 6262 class C { |
| 6263 final dynamic x; |
| 6264 C(); |
| 6265 } |
| 6266 class D { |
| 6267 final dynamic x; |
| 6268 D(); |
| 6269 } |
| 6270 '''); |
| 6271 } else { |
| 6272 checkElementText( |
| 6273 library, |
| 6274 r''' |
| 6275 class C { |
| 6276 final dynamic x; |
| 6277 C(); |
| 6278 } |
| 6279 class D { |
| 6280 final dynamic x; |
| 6281 D(); |
| 6282 } |
| 6283 '''); |
| 6284 } |
| 2864 } | 6285 } |
| 2865 | 6286 |
| 2866 test_defaultValue_refersToGenericClass_constructor() { | 6287 test_defaultValue_refersToGenericClass_constructor() { |
| 2867 checkLibrary(''' | 6288 var library = checkLibrary(''' |
| 2868 class B<T> { | 6289 class B<T> { |
| 2869 const B(); | 6290 const B(); |
| 2870 } | 6291 } |
| 6292 class C<T> { |
| 6293 const C([B<T> b = const B()]); |
| 6294 } |
| 6295 '''); |
| 6296 if (isStrongMode) { |
| 6297 checkElementText( |
| 6298 library, |
| 6299 r''' |
| 6300 class B<T> { |
| 6301 const B(); |
| 6302 } |
| 6303 class C<T> { |
| 6304 const C([B<T> b = const B()]); |
| 6305 } |
| 6306 '''); |
| 6307 } else { |
| 6308 checkElementText( |
| 6309 library, |
| 6310 r''' |
| 6311 class B<T> { |
| 6312 const B(); |
| 6313 } |
| 2871 class C<T> { | 6314 class C<T> { |
| 2872 const C([B<T> b = const B()]); | 6315 const C([B<T> b = const B()]); |
| 2873 } | 6316 } |
| 2874 '''); | 6317 '''); |
| 6318 } |
| 2875 } | 6319 } |
| 2876 | 6320 |
| 2877 test_defaultValue_refersToGenericClass_constructor2() { | 6321 test_defaultValue_refersToGenericClass_constructor2() { |
| 2878 checkLibrary(''' | 6322 var library = checkLibrary(''' |
| 2879 abstract class A<T> {} | 6323 abstract class A<T> {} |
| 2880 class B<T> implements A<T> { | 6324 class B<T> implements A<T> { |
| 2881 const B(); | 6325 const B(); |
| 2882 } | 6326 } |
| 2883 class C<T> implements A<Iterable<T>> { | 6327 class C<T> implements A<Iterable<T>> { |
| 2884 const C([A<T> a = const B()]); | 6328 const C([A<T> a = const B()]); |
| 2885 } | 6329 } |
| 2886 '''); | 6330 '''); |
| 6331 if (isStrongMode) { |
| 6332 checkElementText( |
| 6333 library, |
| 6334 r''' |
| 6335 abstract class A<T> { |
| 6336 } |
| 6337 class B<T> implements A<T> { |
| 6338 const B(); |
| 6339 } |
| 6340 class C<T> implements A<Iterable<T>> { |
| 6341 const C([A<T> a = const B()]); |
| 6342 } |
| 6343 '''); |
| 6344 } else { |
| 6345 checkElementText( |
| 6346 library, |
| 6347 r''' |
| 6348 abstract class A<T> { |
| 6349 } |
| 6350 class B<T> implements A<T> { |
| 6351 const B(); |
| 6352 } |
| 6353 class C<T> implements A<Iterable<T>> { |
| 6354 const C([A<T> a = const B()]); |
| 6355 } |
| 6356 '''); |
| 6357 } |
| 2887 } | 6358 } |
| 2888 | 6359 |
| 2889 test_defaultValue_refersToGenericClass_functionG() { | 6360 test_defaultValue_refersToGenericClass_functionG() { |
| 2890 checkLibrary(''' | 6361 var library = checkLibrary(''' |
| 2891 class B<T> { | 6362 class B<T> { |
| 2892 const B(); | 6363 const B(); |
| 2893 } | 6364 } |
| 2894 void foo<T>([B<T> b = const B()]) {} | 6365 void foo<T>([B<T> b = const B()]) {} |
| 2895 '''); | 6366 '''); |
| 6367 if (isStrongMode) { |
| 6368 checkElementText( |
| 6369 library, |
| 6370 r''' |
| 6371 class B<T> { |
| 6372 const B(); |
| 6373 } |
| 6374 void foo<T>([B<T> b = const B()]) {} |
| 6375 '''); |
| 6376 } else { |
| 6377 checkElementText( |
| 6378 library, |
| 6379 r''' |
| 6380 class B<T> { |
| 6381 const B(); |
| 6382 } |
| 6383 void foo<T>([B<T> b = const B()]) {} |
| 6384 '''); |
| 6385 } |
| 2896 } | 6386 } |
| 2897 | 6387 |
| 2898 test_defaultValue_refersToGenericClass_methodG() { | 6388 test_defaultValue_refersToGenericClass_methodG() { |
| 2899 checkLibrary(''' | 6389 var library = checkLibrary(''' |
| 2900 class B<T> { | 6390 class B<T> { |
| 2901 const B(); | 6391 const B(); |
| 2902 } | 6392 } |
| 6393 class C { |
| 6394 void foo<T>([B<T> b = const B()]) {} |
| 6395 } |
| 6396 '''); |
| 6397 if (isStrongMode) { |
| 6398 checkElementText( |
| 6399 library, |
| 6400 r''' |
| 6401 class B<T> { |
| 6402 const B(); |
| 6403 } |
| 2903 class C { | 6404 class C { |
| 2904 void foo<T>([B<T> b = const B()]) {} | 6405 void foo<T>([B<T> b = const B()]) {} |
| 2905 } | 6406 } |
| 2906 '''); | 6407 '''); |
| 6408 } else { |
| 6409 checkElementText( |
| 6410 library, |
| 6411 r''' |
| 6412 class B<T> { |
| 6413 const B(); |
| 6414 } |
| 6415 class C { |
| 6416 void foo<T>([B<T> b = const B()]) {} |
| 6417 } |
| 6418 '''); |
| 6419 } |
| 2907 } | 6420 } |
| 2908 | 6421 |
| 2909 test_defaultValue_refersToGenericClass_methodG_classG() { | 6422 test_defaultValue_refersToGenericClass_methodG_classG() { |
| 2910 checkLibrary(''' | 6423 var library = checkLibrary(''' |
| 2911 class B<T1, T2> { | 6424 class B<T1, T2> { |
| 2912 const B(); | 6425 const B(); |
| 2913 } | 6426 } |
| 6427 class C<E1> { |
| 6428 void foo<E2>([B<E1, E2> b = const B()]) {} |
| 6429 } |
| 6430 '''); |
| 6431 if (isStrongMode) { |
| 6432 checkElementText( |
| 6433 library, |
| 6434 r''' |
| 6435 class B<T1, T2> { |
| 6436 const B(); |
| 6437 } |
| 6438 class C<E1> { |
| 6439 void foo<E2>([B<E1, E2> b = const B()]) {} |
| 6440 } |
| 6441 '''); |
| 6442 } else { |
| 6443 checkElementText( |
| 6444 library, |
| 6445 r''' |
| 6446 class B<T1, T2> { |
| 6447 const B(); |
| 6448 } |
| 2914 class C<E1> { | 6449 class C<E1> { |
| 2915 void foo<E2>([B<E1, E2> b = const B()]) {} | 6450 void foo<E2>([B<E1, E2> b = const B()]) {} |
| 2916 } | 6451 } |
| 2917 '''); | 6452 '''); |
| 6453 } |
| 2918 } | 6454 } |
| 2919 | 6455 |
| 2920 test_defaultValue_refersToGenericClass_methodNG() { | 6456 test_defaultValue_refersToGenericClass_methodNG() { |
| 2921 checkLibrary(''' | 6457 var library = checkLibrary(''' |
| 2922 class B<T> { | 6458 class B<T> { |
| 2923 const B(); | 6459 const B(); |
| 2924 } | 6460 } |
| 6461 class C<T> { |
| 6462 void foo([B<T> b = const B()]) {} |
| 6463 } |
| 6464 '''); |
| 6465 if (isStrongMode) { |
| 6466 checkElementText( |
| 6467 library, |
| 6468 r''' |
| 6469 class B<T> { |
| 6470 const B(); |
| 6471 } |
| 6472 class C<T> { |
| 6473 void foo([B<T> b = const B()]) {} |
| 6474 } |
| 6475 '''); |
| 6476 } else { |
| 6477 checkElementText( |
| 6478 library, |
| 6479 r''' |
| 6480 class B<T> { |
| 6481 const B(); |
| 6482 } |
| 2925 class C<T> { | 6483 class C<T> { |
| 2926 void foo([B<T> b = const B()]) {} | 6484 void foo([B<T> b = const B()]) {} |
| 2927 } | 6485 } |
| 2928 '''); | 6486 '''); |
| 6487 } |
| 2929 } | 6488 } |
| 2930 | 6489 |
| 2931 test_enum_documented() { | 6490 test_enum_documented() { |
| 2932 checkLibrary(''' | 6491 var library = checkLibrary(''' |
| 2933 // Extra comment so doc comment offset != 0 | 6492 // Extra comment so doc comment offset != 0 |
| 2934 /** | 6493 /** |
| 2935 * Docs | 6494 * Docs |
| 2936 */ | 6495 */ |
| 2937 enum E { v }'''); | 6496 enum E { v }'''); |
| 6497 if (isStrongMode) { |
| 6498 checkElementText( |
| 6499 library, |
| 6500 r''' |
| 6501 /** |
| 6502 * Docs |
| 6503 */ |
| 6504 enum E { |
| 6505 final int index; |
| 6506 static const List<E> values; |
| 6507 static const E v; |
| 6508 } |
| 6509 '''); |
| 6510 } else { |
| 6511 checkElementText( |
| 6512 library, |
| 6513 r''' |
| 6514 /** |
| 6515 * Docs |
| 6516 */ |
| 6517 enum E { |
| 6518 final int index; |
| 6519 static const List<E> values; |
| 6520 static const E v; |
| 6521 } |
| 6522 '''); |
| 6523 } |
| 2938 } | 6524 } |
| 2939 | 6525 |
| 2940 test_enum_value_documented() { | 6526 test_enum_value_documented() { |
| 2941 checkLibrary(''' | 6527 var library = checkLibrary(''' |
| 2942 enum E { | 6528 enum E { |
| 2943 /** | 6529 /** |
| 2944 * Docs | 6530 * Docs |
| 2945 */ | 6531 */ |
| 2946 v | 6532 v |
| 2947 }'''); | 6533 }'''); |
| 6534 if (isStrongMode) { |
| 6535 checkElementText( |
| 6536 library, |
| 6537 r''' |
| 6538 enum E { |
| 6539 final int index; |
| 6540 static const List<E> values; |
| 6541 /** |
| 6542 * Docs |
| 6543 */ |
| 6544 static const E v; |
| 6545 } |
| 6546 '''); |
| 6547 } else { |
| 6548 checkElementText( |
| 6549 library, |
| 6550 r''' |
| 6551 enum E { |
| 6552 final int index; |
| 6553 static const List<E> values; |
| 6554 /** |
| 6555 * Docs |
| 6556 */ |
| 6557 static const E v; |
| 6558 } |
| 6559 '''); |
| 6560 } |
| 2948 } | 6561 } |
| 2949 | 6562 |
| 2950 test_enum_values() { | 6563 test_enum_values() { |
| 2951 checkLibrary('enum E { v1, v2 }'); | 6564 var library = checkLibrary('enum E { v1, v2 }'); |
| 6565 if (isStrongMode) { |
| 6566 checkElementText( |
| 6567 library, |
| 6568 r''' |
| 6569 enum E { |
| 6570 final int index; |
| 6571 static const List<E> values; |
| 6572 static const E v1; |
| 6573 static const E v2; |
| 6574 } |
| 6575 '''); |
| 6576 } else { |
| 6577 checkElementText( |
| 6578 library, |
| 6579 r''' |
| 6580 enum E { |
| 6581 final int index; |
| 6582 static const List<E> values; |
| 6583 static const E v1; |
| 6584 static const E v2; |
| 6585 } |
| 6586 '''); |
| 6587 } |
| 2952 } | 6588 } |
| 2953 | 6589 |
| 2954 test_enums() { | 6590 test_enums() { |
| 2955 checkLibrary('enum E1 { v1 } enum E2 { v2 }'); | 6591 var library = checkLibrary('enum E1 { v1 } enum E2 { v2 }'); |
| 6592 if (isStrongMode) { |
| 6593 checkElementText( |
| 6594 library, |
| 6595 r''' |
| 6596 enum E1 { |
| 6597 final int index; |
| 6598 static const List<E1> values; |
| 6599 static const E1 v1; |
| 6600 } |
| 6601 enum E2 { |
| 6602 final int index; |
| 6603 static const List<E2> values; |
| 6604 static const E2 v2; |
| 6605 } |
| 6606 '''); |
| 6607 } else { |
| 6608 checkElementText( |
| 6609 library, |
| 6610 r''' |
| 6611 enum E1 { |
| 6612 final int index; |
| 6613 static const List<E1> values; |
| 6614 static const E1 v1; |
| 6615 } |
| 6616 enum E2 { |
| 6617 final int index; |
| 6618 static const List<E2> values; |
| 6619 static const E2 v2; |
| 6620 } |
| 6621 '''); |
| 6622 } |
| 2956 } | 6623 } |
| 2957 | 6624 |
| 2958 test_error_extendsEnum() { | 6625 test_error_extendsEnum() { |
| 2959 checkLibrary(''' | 6626 var library = checkLibrary(''' |
| 2960 enum E {a, b, c} | 6627 enum E {a, b, c} |
| 2961 | 6628 |
| 2962 class M {} | 6629 class M {} |
| 2963 | 6630 |
| 2964 class A extends E { | 6631 class A extends E { |
| 2965 foo() {} | 6632 foo() {} |
| 2966 } | 6633 } |
| 2967 | 6634 |
| 2968 class B implements E, M { | 6635 class B implements E, M { |
| 2969 foo() {} | 6636 foo() {} |
| 2970 } | 6637 } |
| 2971 | 6638 |
| 2972 class C extends Object with E, M { | 6639 class C extends Object with E, M { |
| 2973 foo() {} | 6640 foo() {} |
| 2974 } | 6641 } |
| 2975 | 6642 |
| 2976 class D = Object with M, E; | 6643 class D = Object with M, E; |
| 2977 '''); | 6644 '''); |
| 6645 if (isStrongMode) { |
| 6646 checkElementText( |
| 6647 library, |
| 6648 r''' |
| 6649 enum E { |
| 6650 final int index; |
| 6651 static const List<E> values; |
| 6652 static const E a; |
| 6653 static const E b; |
| 6654 static const E c; |
| 6655 } |
| 6656 class M { |
| 6657 } |
| 6658 class A { |
| 6659 dynamic foo() {} |
| 6660 } |
| 6661 class B implements M { |
| 6662 dynamic foo() {} |
| 6663 } |
| 6664 class C extends Object with M { |
| 6665 synthetic C(); |
| 6666 dynamic foo() {} |
| 6667 } |
| 6668 class alias D extends Object with M { |
| 6669 synthetic D() = Object; |
| 6670 } |
| 6671 '''); |
| 6672 } else { |
| 6673 checkElementText( |
| 6674 library, |
| 6675 r''' |
| 6676 enum E { |
| 6677 final int index; |
| 6678 static const List<E> values; |
| 6679 static const E a; |
| 6680 static const E b; |
| 6681 static const E c; |
| 6682 } |
| 6683 class M { |
| 6684 } |
| 6685 class A { |
| 6686 dynamic foo() {} |
| 6687 } |
| 6688 class B implements M { |
| 6689 dynamic foo() {} |
| 6690 } |
| 6691 class C extends Object with M { |
| 6692 synthetic C(); |
| 6693 dynamic foo() {} |
| 6694 } |
| 6695 class alias D extends Object with M { |
| 6696 synthetic D() = Object; |
| 6697 } |
| 6698 '''); |
| 6699 } |
| 2978 } | 6700 } |
| 2979 | 6701 |
| 2980 test_executable_parameter_type_typedef() { | 6702 test_executable_parameter_type_typedef() { |
| 2981 checkLibrary(r''' | 6703 var library = checkLibrary(r''' |
| 2982 typedef F(int p); | 6704 typedef F(int p); |
| 2983 main(F f) {} | 6705 main(F f) {} |
| 2984 '''); | 6706 '''); |
| 6707 if (isStrongMode) { |
| 6708 checkElementText( |
| 6709 library, |
| 6710 r''' |
| 6711 typedef dynamic F(int p); |
| 6712 dynamic main(F f) {} |
| 6713 '''); |
| 6714 } else { |
| 6715 checkElementText( |
| 6716 library, |
| 6717 r''' |
| 6718 typedef dynamic F(int p); |
| 6719 dynamic main(F f) {} |
| 6720 '''); |
| 6721 } |
| 2985 } | 6722 } |
| 2986 | 6723 |
| 2987 test_export_class() { | 6724 test_export_class() { |
| 2988 addLibrarySource('/a.dart', 'class C {}'); | 6725 addLibrarySource('/a.dart', 'class C {}'); |
| 2989 checkLibrary('export "a.dart";'); | 6726 var library = checkLibrary('export "a.dart";'); |
| 6727 if (isStrongMode) { |
| 6728 checkElementText( |
| 6729 library, |
| 6730 r''' |
| 6731 export 'a.dart'; |
| 6732 '''); |
| 6733 } else { |
| 6734 checkElementText( |
| 6735 library, |
| 6736 r''' |
| 6737 export 'a.dart'; |
| 6738 '''); |
| 6739 } |
| 2990 } | 6740 } |
| 2991 | 6741 |
| 2992 test_export_class_type_alias() { | 6742 test_export_class_type_alias() { |
| 2993 addLibrarySource( | 6743 addLibrarySource( |
| 2994 '/a.dart', 'class C {} exends _D with _E; class _D {} class _E {}'); | 6744 '/a.dart', 'class C {} exends _D with _E; class _D {} class _E {}'); |
| 2995 checkLibrary('export "a.dart";'); | 6745 var library = checkLibrary('export "a.dart";'); |
| 6746 if (isStrongMode) { |
| 6747 checkElementText( |
| 6748 library, |
| 6749 r''' |
| 6750 export 'a.dart'; |
| 6751 '''); |
| 6752 } else { |
| 6753 checkElementText( |
| 6754 library, |
| 6755 r''' |
| 6756 export 'a.dart'; |
| 6757 '''); |
| 6758 } |
| 2996 } | 6759 } |
| 2997 | 6760 |
| 2998 test_export_configurations_useDefault() { | 6761 test_export_configurations_useDefault() { |
| 2999 context.declaredVariables.define('dart.library.io', 'false'); | 6762 context.declaredVariables.define('dart.library.io', 'false'); |
| 3000 addLibrarySource('/foo.dart', 'class A {}'); | 6763 addLibrarySource('/foo.dart', 'class A {}'); |
| 3001 addLibrarySource('/foo_io.dart', 'class A {}'); | 6764 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3002 addLibrarySource('/foo_html.dart', 'class A {}'); | 6765 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3003 LibraryElementImpl library = checkLibrary(r''' | 6766 LibraryElementImpl library = checkLibrary(r''' |
| 3004 export 'foo.dart' | 6767 export 'foo.dart' |
| 3005 if (dart.library.io) 'foo_io.dart' | 6768 if (dart.library.io) 'foo_io.dart' |
| 3006 if (dart.library.html) 'foo_html.dart'; | 6769 if (dart.library.html) 'foo_html.dart'; |
| 3007 '''); | 6770 '''); |
| 6771 if (isStrongMode) { |
| 6772 checkElementText( |
| 6773 library, |
| 6774 r''' |
| 6775 export 'foo.dart'; |
| 6776 '''); |
| 6777 } else { |
| 6778 checkElementText( |
| 6779 library, |
| 6780 r''' |
| 6781 export 'foo.dart'; |
| 6782 '''); |
| 6783 } |
| 3008 expect(library.exports[0].uri, 'foo.dart'); | 6784 expect(library.exports[0].uri, 'foo.dart'); |
| 3009 expect(library.exports[0].exportedLibrary.source.shortName, 'foo.dart'); | 6785 expect(library.exports[0].exportedLibrary.source.shortName, 'foo.dart'); |
| 3010 } | 6786 } |
| 3011 | 6787 |
| 3012 test_export_configurations_useFirst() { | 6788 test_export_configurations_useFirst() { |
| 3013 context.declaredVariables.define('dart.library.io', 'true'); | 6789 context.declaredVariables.define('dart.library.io', 'true'); |
| 3014 context.declaredVariables.define('dart.library.html', 'true'); | 6790 context.declaredVariables.define('dart.library.html', 'true'); |
| 3015 addLibrarySource('/foo.dart', 'class A {}'); | 6791 addLibrarySource('/foo.dart', 'class A {}'); |
| 3016 addLibrarySource('/foo_io.dart', 'class A {}'); | 6792 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3017 addLibrarySource('/foo_html.dart', 'class A {}'); | 6793 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3018 LibraryElementImpl library = checkLibrary(r''' | 6794 LibraryElementImpl library = checkLibrary(r''' |
| 3019 export 'foo.dart' | 6795 export 'foo.dart' |
| 3020 if (dart.library.io) 'foo_io.dart' | 6796 if (dart.library.io) 'foo_io.dart' |
| 3021 if (dart.library.html) 'foo_html.dart'; | 6797 if (dart.library.html) 'foo_html.dart'; |
| 3022 '''); | 6798 '''); |
| 6799 if (isStrongMode) { |
| 6800 checkElementText( |
| 6801 library, |
| 6802 r''' |
| 6803 export 'foo_io.dart'; |
| 6804 '''); |
| 6805 } else { |
| 6806 checkElementText( |
| 6807 library, |
| 6808 r''' |
| 6809 export 'foo_io.dart'; |
| 6810 '''); |
| 6811 } |
| 3023 expect(library.exports[0].uri, 'foo_io.dart'); | 6812 expect(library.exports[0].uri, 'foo_io.dart'); |
| 3024 expect(library.exports[0].exportedLibrary.source.shortName, 'foo_io.dart'); | 6813 expect(library.exports[0].exportedLibrary.source.shortName, 'foo_io.dart'); |
| 3025 } | 6814 } |
| 3026 | 6815 |
| 3027 test_export_configurations_useSecond() { | 6816 test_export_configurations_useSecond() { |
| 3028 context.declaredVariables.define('dart.library.io', 'false'); | 6817 context.declaredVariables.define('dart.library.io', 'false'); |
| 3029 context.declaredVariables.define('dart.library.html', 'true'); | 6818 context.declaredVariables.define('dart.library.html', 'true'); |
| 3030 addLibrarySource('/foo.dart', 'class A {}'); | 6819 addLibrarySource('/foo.dart', 'class A {}'); |
| 3031 addLibrarySource('/foo_io.dart', 'class A {}'); | 6820 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3032 addLibrarySource('/foo_html.dart', 'class A {}'); | 6821 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3033 LibraryElementImpl library = checkLibrary(r''' | 6822 LibraryElementImpl library = checkLibrary(r''' |
| 3034 export 'foo.dart' | 6823 export 'foo.dart' |
| 3035 if (dart.library.io) 'foo_io.dart' | 6824 if (dart.library.io) 'foo_io.dart' |
| 3036 if (dart.library.html) 'foo_html.dart'; | 6825 if (dart.library.html) 'foo_html.dart'; |
| 3037 '''); | 6826 '''); |
| 6827 if (isStrongMode) { |
| 6828 checkElementText( |
| 6829 library, |
| 6830 r''' |
| 6831 export 'foo_html.dart'; |
| 6832 '''); |
| 6833 } else { |
| 6834 checkElementText( |
| 6835 library, |
| 6836 r''' |
| 6837 export 'foo_html.dart'; |
| 6838 '''); |
| 6839 } |
| 3038 ExportElement export = library.exports[0]; | 6840 ExportElement export = library.exports[0]; |
| 3039 expect(export.uri, 'foo_html.dart'); | 6841 expect(export.uri, 'foo_html.dart'); |
| 3040 expect(export.exportedLibrary.source.shortName, 'foo_html.dart'); | 6842 expect(export.exportedLibrary.source.shortName, 'foo_html.dart'); |
| 3041 } | 6843 } |
| 3042 | 6844 |
| 3043 test_export_function() { | 6845 test_export_function() { |
| 3044 addLibrarySource('/a.dart', 'f() {}'); | 6846 addLibrarySource('/a.dart', 'f() {}'); |
| 3045 checkLibrary('export "a.dart";'); | 6847 var library = checkLibrary('export "a.dart";'); |
| 6848 if (isStrongMode) { |
| 6849 checkElementText( |
| 6850 library, |
| 6851 r''' |
| 6852 export 'a.dart'; |
| 6853 '''); |
| 6854 } else { |
| 6855 checkElementText( |
| 6856 library, |
| 6857 r''' |
| 6858 export 'a.dart'; |
| 6859 '''); |
| 6860 } |
| 3046 } | 6861 } |
| 3047 | 6862 |
| 3048 test_export_getter() { | 6863 test_export_getter() { |
| 3049 addLibrarySource('/a.dart', 'get f() => null;'); | 6864 addLibrarySource('/a.dart', 'get f() => null;'); |
| 3050 checkLibrary('export "a.dart";'); | 6865 var library = checkLibrary('export "a.dart";'); |
| 6866 if (isStrongMode) { |
| 6867 checkElementText( |
| 6868 library, |
| 6869 r''' |
| 6870 export 'a.dart'; |
| 6871 '''); |
| 6872 } else { |
| 6873 checkElementText( |
| 6874 library, |
| 6875 r''' |
| 6876 export 'a.dart'; |
| 6877 '''); |
| 6878 } |
| 3051 } | 6879 } |
| 3052 | 6880 |
| 3053 test_export_hide() { | 6881 test_export_hide() { |
| 3054 addLibrary('dart:async'); | 6882 addLibrary('dart:async'); |
| 3055 checkLibrary('export "dart:async" hide Stream, Future;'); | 6883 var library = checkLibrary('export "dart:async" hide Stream, Future;'); |
| 6884 if (isStrongMode) { |
| 6885 checkElementText( |
| 6886 library, |
| 6887 r''' |
| 6888 export 'dart:async' hide Stream, Future; |
| 6889 '''); |
| 6890 } else { |
| 6891 checkElementText( |
| 6892 library, |
| 6893 r''' |
| 6894 export 'dart:async' hide Stream, Future; |
| 6895 '''); |
| 6896 } |
| 3056 } | 6897 } |
| 3057 | 6898 |
| 3058 test_export_multiple_combinators() { | 6899 test_export_multiple_combinators() { |
| 3059 addLibrary('dart:async'); | 6900 addLibrary('dart:async'); |
| 3060 checkLibrary('export "dart:async" hide Stream show Future;'); | 6901 var library = checkLibrary('export "dart:async" hide Stream show Future;'); |
| 6902 if (isStrongMode) { |
| 6903 checkElementText( |
| 6904 library, |
| 6905 r''' |
| 6906 export 'dart:async' hide Stream show Future; |
| 6907 '''); |
| 6908 } else { |
| 6909 checkElementText( |
| 6910 library, |
| 6911 r''' |
| 6912 export 'dart:async' hide Stream show Future; |
| 6913 '''); |
| 6914 } |
| 3061 } | 6915 } |
| 3062 | 6916 |
| 3063 test_export_setter() { | 6917 test_export_setter() { |
| 3064 addLibrarySource('/a.dart', 'void set f(value) {}'); | 6918 addLibrarySource('/a.dart', 'void set f(value) {}'); |
| 3065 checkLibrary('export "a.dart";'); | 6919 var library = checkLibrary('export "a.dart";'); |
| 6920 if (isStrongMode) { |
| 6921 checkElementText( |
| 6922 library, |
| 6923 r''' |
| 6924 export 'a.dart'; |
| 6925 '''); |
| 6926 } else { |
| 6927 checkElementText( |
| 6928 library, |
| 6929 r''' |
| 6930 export 'a.dart'; |
| 6931 '''); |
| 6932 } |
| 3066 } | 6933 } |
| 3067 | 6934 |
| 3068 test_export_show() { | 6935 test_export_show() { |
| 3069 addLibrary('dart:async'); | 6936 addLibrary('dart:async'); |
| 3070 checkLibrary('export "dart:async" show Future, Stream;'); | 6937 var library = checkLibrary('export "dart:async" show Future, Stream;'); |
| 6938 if (isStrongMode) { |
| 6939 checkElementText( |
| 6940 library, |
| 6941 r''' |
| 6942 export 'dart:async' show Future, Stream; |
| 6943 '''); |
| 6944 } else { |
| 6945 checkElementText( |
| 6946 library, |
| 6947 r''' |
| 6948 export 'dart:async' show Future, Stream; |
| 6949 '''); |
| 6950 } |
| 3071 } | 6951 } |
| 3072 | 6952 |
| 3073 test_export_typedef() { | 6953 test_export_typedef() { |
| 3074 addLibrarySource('/a.dart', 'typedef F();'); | 6954 addLibrarySource('/a.dart', 'typedef F();'); |
| 3075 checkLibrary('export "a.dart";'); | 6955 var library = checkLibrary('export "a.dart";'); |
| 6956 if (isStrongMode) { |
| 6957 checkElementText( |
| 6958 library, |
| 6959 r''' |
| 6960 export 'a.dart'; |
| 6961 '''); |
| 6962 } else { |
| 6963 checkElementText( |
| 6964 library, |
| 6965 r''' |
| 6966 export 'a.dart'; |
| 6967 '''); |
| 6968 } |
| 3076 } | 6969 } |
| 3077 | 6970 |
| 3078 test_export_variable() { | 6971 test_export_variable() { |
| 3079 addLibrarySource('/a.dart', 'var x;'); | 6972 addLibrarySource('/a.dart', 'var x;'); |
| 3080 checkLibrary('export "a.dart";'); | 6973 var library = checkLibrary('export "a.dart";'); |
| 6974 if (isStrongMode) { |
| 6975 checkElementText( |
| 6976 library, |
| 6977 r''' |
| 6978 export 'a.dart'; |
| 6979 '''); |
| 6980 } else { |
| 6981 checkElementText( |
| 6982 library, |
| 6983 r''' |
| 6984 export 'a.dart'; |
| 6985 '''); |
| 6986 } |
| 3081 } | 6987 } |
| 3082 | 6988 |
| 3083 test_export_variable_const() { | 6989 test_export_variable_const() { |
| 3084 addLibrarySource('/a.dart', 'const x = 0;'); | 6990 addLibrarySource('/a.dart', 'const x = 0;'); |
| 3085 checkLibrary('export "a.dart";'); | 6991 var library = checkLibrary('export "a.dart";'); |
| 6992 if (isStrongMode) { |
| 6993 checkElementText( |
| 6994 library, |
| 6995 r''' |
| 6996 export 'a.dart'; |
| 6997 '''); |
| 6998 } else { |
| 6999 checkElementText( |
| 7000 library, |
| 7001 r''' |
| 7002 export 'a.dart'; |
| 7003 '''); |
| 7004 } |
| 3086 } | 7005 } |
| 3087 | 7006 |
| 3088 test_export_variable_final() { | 7007 test_export_variable_final() { |
| 3089 addLibrarySource('/a.dart', 'final x = 0;'); | 7008 addLibrarySource('/a.dart', 'final x = 0;'); |
| 3090 checkLibrary('export "a.dart";'); | 7009 var library = checkLibrary('export "a.dart";'); |
| 7010 if (isStrongMode) { |
| 7011 checkElementText( |
| 7012 library, |
| 7013 r''' |
| 7014 export 'a.dart'; |
| 7015 '''); |
| 7016 } else { |
| 7017 checkElementText( |
| 7018 library, |
| 7019 r''' |
| 7020 export 'a.dart'; |
| 7021 '''); |
| 7022 } |
| 3091 } | 7023 } |
| 3092 | 7024 |
| 3093 test_exportImport_configurations_useDefault() { | 7025 test_exportImport_configurations_useDefault() { |
| 3094 context.declaredVariables.define('dart.library.io', 'false'); | 7026 context.declaredVariables.define('dart.library.io', 'false'); |
| 3095 addLibrarySource('/foo.dart', 'class A {}'); | 7027 addLibrarySource('/foo.dart', 'class A {}'); |
| 3096 addLibrarySource('/foo_io.dart', 'class A {}'); | 7028 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3097 addLibrarySource('/foo_html.dart', 'class A {}'); | 7029 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3098 addLibrarySource( | 7030 addLibrarySource( |
| 3099 '/bar.dart', | 7031 '/bar.dart', |
| 3100 r''' | 7032 r''' |
| 3101 export 'foo.dart' | 7033 export 'foo.dart' |
| 3102 if (dart.library.io) 'foo_io.dart' | 7034 if (dart.library.io) 'foo_io.dart' |
| 3103 if (dart.library.html) 'foo_html.dart'; | 7035 if (dart.library.html) 'foo_html.dart'; |
| 3104 '''); | 7036 '''); |
| 3105 LibraryElementImpl library = checkLibrary(r''' | 7037 LibraryElementImpl library = checkLibrary(r''' |
| 3106 import 'bar.dart'; | 7038 import 'bar.dart'; |
| 3107 class B extends A {} | 7039 class B extends A {} |
| 3108 '''); | 7040 '''); |
| 7041 if (isStrongMode) { |
| 7042 checkElementText( |
| 7043 library, |
| 7044 r''' |
| 7045 import 'bar.dart'; |
| 7046 class B extends A { |
| 7047 } |
| 7048 '''); |
| 7049 } else { |
| 7050 checkElementText( |
| 7051 library, |
| 7052 r''' |
| 7053 import 'bar.dart'; |
| 7054 class B extends A { |
| 7055 } |
| 7056 '''); |
| 7057 } |
| 3109 var typeA = library.definingCompilationUnit.getType('B').supertype; | 7058 var typeA = library.definingCompilationUnit.getType('B').supertype; |
| 3110 expect(typeA.element.source.shortName, 'foo.dart'); | 7059 expect(typeA.element.source.shortName, 'foo.dart'); |
| 3111 } | 7060 } |
| 3112 | 7061 |
| 3113 test_exportImport_configurations_useFirst() { | 7062 test_exportImport_configurations_useFirst() { |
| 3114 context.declaredVariables.define('dart.library.io', 'true'); | 7063 context.declaredVariables.define('dart.library.io', 'true'); |
| 3115 context.declaredVariables.define('dart.library.html', 'true'); | 7064 context.declaredVariables.define('dart.library.html', 'true'); |
| 3116 addLibrarySource('/foo.dart', 'class A {}'); | 7065 addLibrarySource('/foo.dart', 'class A {}'); |
| 3117 addLibrarySource('/foo_io.dart', 'class A {}'); | 7066 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3118 addLibrarySource('/foo_html.dart', 'class A {}'); | 7067 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3119 addLibrarySource( | 7068 addLibrarySource( |
| 3120 '/bar.dart', | 7069 '/bar.dart', |
| 3121 r''' | 7070 r''' |
| 3122 export 'foo.dart' | 7071 export 'foo.dart' |
| 3123 if (dart.library.io) 'foo_io.dart' | 7072 if (dart.library.io) 'foo_io.dart' |
| 3124 if (dart.library.html) 'foo_html.dart'; | 7073 if (dart.library.html) 'foo_html.dart'; |
| 3125 '''); | 7074 '''); |
| 3126 var library = checkLibrary(r''' | 7075 var library = checkLibrary(r''' |
| 3127 import 'bar.dart'; | 7076 import 'bar.dart'; |
| 3128 class B extends A {} | 7077 class B extends A {} |
| 3129 '''); | 7078 '''); |
| 7079 if (isStrongMode) { |
| 7080 checkElementText( |
| 7081 library, |
| 7082 r''' |
| 7083 import 'bar.dart'; |
| 7084 class B extends A { |
| 7085 } |
| 7086 '''); |
| 7087 } else { |
| 7088 checkElementText( |
| 7089 library, |
| 7090 r''' |
| 7091 import 'bar.dart'; |
| 7092 class B extends A { |
| 7093 } |
| 7094 '''); |
| 7095 } |
| 3130 var typeA = library.definingCompilationUnit.getType('B').supertype; | 7096 var typeA = library.definingCompilationUnit.getType('B').supertype; |
| 3131 expect(typeA.element.source.shortName, 'foo_io.dart'); | 7097 expect(typeA.element.source.shortName, 'foo_io.dart'); |
| 3132 } | 7098 } |
| 3133 | 7099 |
| 3134 test_exports() { | 7100 test_exports() { |
| 3135 addLibrarySource('/a.dart', 'library a;'); | 7101 addLibrarySource('/a.dart', 'library a;'); |
| 3136 addLibrarySource('/b.dart', 'library b;'); | 7102 addLibrarySource('/b.dart', 'library b;'); |
| 3137 checkLibrary('export "a.dart"; export "b.dart";'); | 7103 var library = checkLibrary('export "a.dart"; export "b.dart";'); |
| 7104 if (isStrongMode) { |
| 7105 checkElementText( |
| 7106 library, |
| 7107 r''' |
| 7108 export 'a.dart'; |
| 7109 export 'b.dart'; |
| 7110 '''); |
| 7111 } else { |
| 7112 checkElementText( |
| 7113 library, |
| 7114 r''' |
| 7115 export 'a.dart'; |
| 7116 export 'b.dart'; |
| 7117 '''); |
| 7118 } |
| 3138 } | 7119 } |
| 3139 | 7120 |
| 3140 test_expr_invalid_typeParameter_asPrefix() { | 7121 test_expr_invalid_typeParameter_asPrefix() { |
| 3141 variablesWithNotConstInitializers.add('f'); | 7122 variablesWithNotConstInitializers.add('f'); |
| 3142 checkLibrary(''' | 7123 var library = checkLibrary(''' |
| 3143 class C<T> { | 7124 class C<T> { |
| 3144 final f = T.k; | 7125 final f = T.k; |
| 3145 } | 7126 } |
| 3146 '''); | 7127 '''); |
| 7128 if (isStrongMode) { |
| 7129 checkElementText( |
| 7130 library, |
| 7131 r''' |
| 7132 class C<T> { |
| 7133 final dynamic f = $$invalidConstExpr$$; |
| 7134 } |
| 7135 '''); |
| 7136 } else { |
| 7137 checkElementText( |
| 7138 library, |
| 7139 r''' |
| 7140 class C<T> { |
| 7141 final dynamic f = $$invalidConstExpr$$; |
| 7142 } |
| 7143 '''); |
| 7144 } |
| 3147 } | 7145 } |
| 3148 | 7146 |
| 3149 test_field_covariant() { | 7147 test_field_covariant() { |
| 3150 checkLibrary(''' | 7148 var library = checkLibrary(''' |
| 3151 class C { | 7149 class C { |
| 3152 covariant int x; | 7150 covariant int x; |
| 3153 }'''); | 7151 }'''); |
| 7152 if (isStrongMode) { |
| 7153 checkElementText( |
| 7154 library, |
| 7155 r''' |
| 7156 class C { |
| 7157 covariant int x; |
| 7158 } |
| 7159 '''); |
| 7160 } else { |
| 7161 checkElementText( |
| 7162 library, |
| 7163 r''' |
| 7164 class C { |
| 7165 covariant int x; |
| 7166 } |
| 7167 '''); |
| 7168 } |
| 3154 } | 7169 } |
| 3155 | 7170 |
| 3156 test_field_documented() { | 7171 test_field_documented() { |
| 3157 checkLibrary(''' | 7172 var library = checkLibrary(''' |
| 3158 class C { | 7173 class C { |
| 3159 /** | 7174 /** |
| 3160 * Docs | 7175 * Docs |
| 3161 */ | 7176 */ |
| 3162 var x; | 7177 var x; |
| 3163 }'''); | 7178 }'''); |
| 7179 if (isStrongMode) { |
| 7180 checkElementText( |
| 7181 library, |
| 7182 r''' |
| 7183 class C { |
| 7184 /** |
| 7185 * Docs |
| 7186 */ |
| 7187 dynamic x; |
| 7188 } |
| 7189 '''); |
| 7190 } else { |
| 7191 checkElementText( |
| 7192 library, |
| 7193 r''' |
| 7194 class C { |
| 7195 /** |
| 7196 * Docs |
| 7197 */ |
| 7198 dynamic x; |
| 7199 } |
| 7200 '''); |
| 7201 } |
| 3164 } | 7202 } |
| 3165 | 7203 |
| 3166 test_field_formal_param_inferred_type_implicit() { | 7204 test_field_formal_param_inferred_type_implicit() { |
| 3167 checkLibrary('class C extends D { var v; C(this.v); }' | 7205 var library = checkLibrary('class C extends D { var v; C(this.v); }' |
| 3168 ' abstract class D { int get v; }'); | 7206 ' abstract class D { int get v; }'); |
| 7207 if (isStrongMode) { |
| 7208 checkElementText( |
| 7209 library, |
| 7210 r''' |
| 7211 class C extends D { |
| 7212 int v; |
| 7213 C(int this.v); |
| 7214 } |
| 7215 abstract class D { |
| 7216 int get v; |
| 7217 } |
| 7218 '''); |
| 7219 } else { |
| 7220 checkElementText( |
| 7221 library, |
| 7222 r''' |
| 7223 class C extends D { |
| 7224 dynamic v; |
| 7225 C(dynamic this.v); |
| 7226 } |
| 7227 abstract class D { |
| 7228 int get v; |
| 7229 } |
| 7230 '''); |
| 7231 } |
| 3169 } | 7232 } |
| 3170 | 7233 |
| 3171 test_field_inferred_type_nonStatic_explicit_initialized() { | 7234 test_field_inferred_type_nonStatic_explicit_initialized() { |
| 3172 checkLibrary('class C { num v = 0; }'); | 7235 var library = checkLibrary('class C { num v = 0; }'); |
| 7236 if (isStrongMode) { |
| 7237 checkElementText( |
| 7238 library, |
| 7239 r''' |
| 7240 class C { |
| 7241 num v; |
| 7242 } |
| 7243 '''); |
| 7244 } else { |
| 7245 checkElementText( |
| 7246 library, |
| 7247 r''' |
| 7248 class C { |
| 7249 num v; |
| 7250 } |
| 7251 '''); |
| 7252 } |
| 3173 } | 7253 } |
| 3174 | 7254 |
| 3175 test_field_inferred_type_nonStatic_implicit_initialized() { | 7255 test_field_inferred_type_nonStatic_implicit_initialized() { |
| 3176 checkLibrary('class C { var v = 0; }'); | 7256 var library = checkLibrary('class C { var v = 0; }'); |
| 7257 if (isStrongMode) { |
| 7258 checkElementText( |
| 7259 library, |
| 7260 r''' |
| 7261 class C { |
| 7262 int v; |
| 7263 } |
| 7264 '''); |
| 7265 } else { |
| 7266 checkElementText( |
| 7267 library, |
| 7268 r''' |
| 7269 class C { |
| 7270 dynamic v; |
| 7271 } |
| 7272 '''); |
| 7273 } |
| 3177 } | 7274 } |
| 3178 | 7275 |
| 3179 test_field_inferred_type_nonStatic_implicit_uninitialized() { | 7276 test_field_inferred_type_nonStatic_implicit_uninitialized() { |
| 3180 checkLibrary( | 7277 var library = checkLibrary( |
| 3181 'class C extends D { var v; } abstract class D { int get v; }'); | 7278 'class C extends D { var v; } abstract class D { int get v; }'); |
| 7279 if (isStrongMode) { |
| 7280 checkElementText( |
| 7281 library, |
| 7282 r''' |
| 7283 class C extends D { |
| 7284 int v; |
| 7285 } |
| 7286 abstract class D { |
| 7287 int get v; |
| 7288 } |
| 7289 '''); |
| 7290 } else { |
| 7291 checkElementText( |
| 7292 library, |
| 7293 r''' |
| 7294 class C extends D { |
| 7295 dynamic v; |
| 7296 } |
| 7297 abstract class D { |
| 7298 int get v; |
| 7299 } |
| 7300 '''); |
| 7301 } |
| 3182 } | 7302 } |
| 3183 | 7303 |
| 3184 test_field_inferred_type_static_implicit_initialized() { | 7304 test_field_inferred_type_static_implicit_initialized() { |
| 3185 checkLibrary('class C { static var v = 0; }'); | 7305 var library = checkLibrary('class C { static var v = 0; }'); |
| 7306 if (isStrongMode) { |
| 7307 checkElementText( |
| 7308 library, |
| 7309 r''' |
| 7310 class C { |
| 7311 static int v; |
| 7312 } |
| 7313 '''); |
| 7314 } else { |
| 7315 checkElementText( |
| 7316 library, |
| 7317 r''' |
| 7318 class C { |
| 7319 static dynamic v; |
| 7320 } |
| 7321 '''); |
| 7322 } |
| 3186 } | 7323 } |
| 3187 | 7324 |
| 3188 test_field_propagatedType_const_noDep() { | 7325 test_field_propagatedType_const_noDep() { |
| 3189 checkLibrary(''' | 7326 var library = checkLibrary(''' |
| 3190 class C { | 7327 class C { |
| 3191 static const x = 0; | 7328 static const x = 0; |
| 3192 }'''); | 7329 }'''); |
| 7330 if (isStrongMode) { |
| 7331 checkElementText( |
| 7332 library, |
| 7333 r''' |
| 7334 class C { |
| 7335 static const int x = 0; |
| 7336 } |
| 7337 '''); |
| 7338 } else { |
| 7339 checkElementText( |
| 7340 library, |
| 7341 r''' |
| 7342 class C { |
| 7343 static const dynamic x = 0; |
| 7344 } |
| 7345 '''); |
| 7346 } |
| 3193 } | 7347 } |
| 3194 | 7348 |
| 3195 test_field_propagatedType_final_dep_inLib() { | 7349 test_field_propagatedType_final_dep_inLib() { |
| 3196 addLibrarySource('/a.dart', 'final a = 1;'); | 7350 addLibrarySource('/a.dart', 'final a = 1;'); |
| 3197 checkLibrary(''' | 7351 var library = checkLibrary(''' |
| 3198 import "a.dart"; | 7352 import "a.dart"; |
| 3199 class C { | 7353 class C { |
| 3200 final b = a / 2; | 7354 final b = a / 2; |
| 3201 }'''); | 7355 }'''); |
| 7356 if (isStrongMode) { |
| 7357 checkElementText( |
| 7358 library, |
| 7359 r''' |
| 7360 import 'a.dart'; |
| 7361 class C { |
| 7362 final num b = a / 2; |
| 7363 } |
| 7364 '''); |
| 7365 } else { |
| 7366 checkElementText( |
| 7367 library, |
| 7368 r''' |
| 7369 import 'a.dart'; |
| 7370 class C { |
| 7371 final dynamic b = a / 2; |
| 7372 } |
| 7373 '''); |
| 7374 } |
| 3202 } | 7375 } |
| 3203 | 7376 |
| 3204 test_field_propagatedType_final_dep_inPart() { | 7377 test_field_propagatedType_final_dep_inPart() { |
| 3205 addSource('/a.dart', 'part of lib; final a = 1;'); | 7378 addSource('/a.dart', 'part of lib; final a = 1;'); |
| 3206 checkLibrary(''' | 7379 var library = checkLibrary(''' |
| 3207 library lib; | 7380 library lib; |
| 3208 part "a.dart"; | 7381 part "a.dart"; |
| 3209 class C { | 7382 class C { |
| 3210 final b = a / 2; | 7383 final b = a / 2; |
| 3211 }'''); | 7384 }'''); |
| 7385 if (isStrongMode) { |
| 7386 checkElementText( |
| 7387 library, |
| 7388 r''' |
| 7389 library lib; |
| 7390 part 'a.dart'; |
| 7391 class C { |
| 7392 final num b = a / 2; |
| 7393 } |
| 7394 -------------------- |
| 7395 unit: a.dart |
| 7396 |
| 7397 final int a; |
| 7398 '''); |
| 7399 } else { |
| 7400 checkElementText( |
| 7401 library, |
| 7402 r''' |
| 7403 library lib; |
| 7404 part 'a.dart'; |
| 7405 class C { |
| 7406 final dynamic b = a / 2; |
| 7407 } |
| 7408 -------------------- |
| 7409 unit: a.dart |
| 7410 |
| 7411 final dynamic a; |
| 7412 '''); |
| 7413 } |
| 3212 } | 7414 } |
| 3213 | 7415 |
| 3214 test_field_propagatedType_final_noDep_instance() { | 7416 test_field_propagatedType_final_noDep_instance() { |
| 3215 checkLibrary(''' | 7417 var library = checkLibrary(''' |
| 3216 class C { | 7418 class C { |
| 3217 final x = 0; | 7419 final x = 0; |
| 3218 }'''); | 7420 }'''); |
| 7421 if (isStrongMode) { |
| 7422 checkElementText( |
| 7423 library, |
| 7424 r''' |
| 7425 class C { |
| 7426 final int x = 0; |
| 7427 } |
| 7428 '''); |
| 7429 } else { |
| 7430 checkElementText( |
| 7431 library, |
| 7432 r''' |
| 7433 class C { |
| 7434 final dynamic x = 0; |
| 7435 } |
| 7436 '''); |
| 7437 } |
| 3219 } | 7438 } |
| 3220 | 7439 |
| 3221 test_field_propagatedType_final_noDep_static() { | 7440 test_field_propagatedType_final_noDep_static() { |
| 3222 checkLibrary(''' | 7441 var library = checkLibrary(''' |
| 3223 class C { | 7442 class C { |
| 3224 static final x = 0; | 7443 static final x = 0; |
| 3225 }'''); | 7444 }'''); |
| 7445 if (isStrongMode) { |
| 7446 checkElementText( |
| 7447 library, |
| 7448 r''' |
| 7449 class C { |
| 7450 static final int x; |
| 7451 } |
| 7452 '''); |
| 7453 } else { |
| 7454 checkElementText( |
| 7455 library, |
| 7456 r''' |
| 7457 class C { |
| 7458 static final dynamic x; |
| 7459 } |
| 7460 '''); |
| 7461 } |
| 3226 } | 7462 } |
| 3227 | 7463 |
| 3228 test_field_static_final_untyped() { | 7464 test_field_static_final_untyped() { |
| 3229 checkLibrary('class C { static final x = 0; }'); | 7465 var library = checkLibrary('class C { static final x = 0; }'); |
| 7466 if (isStrongMode) { |
| 7467 checkElementText( |
| 7468 library, |
| 7469 r''' |
| 7470 class C { |
| 7471 static final int x; |
| 7472 } |
| 7473 '''); |
| 7474 } else { |
| 7475 checkElementText( |
| 7476 library, |
| 7477 r''' |
| 7478 class C { |
| 7479 static final dynamic x; |
| 7480 } |
| 7481 '''); |
| 7482 } |
| 3230 } | 7483 } |
| 3231 | 7484 |
| 3232 test_field_untyped() { | 7485 test_field_untyped() { |
| 3233 checkLibrary('class C { var x = 0; }'); | 7486 var library = checkLibrary('class C { var x = 0; }'); |
| 7487 if (isStrongMode) { |
| 7488 checkElementText( |
| 7489 library, |
| 7490 r''' |
| 7491 class C { |
| 7492 int x; |
| 7493 } |
| 7494 '''); |
| 7495 } else { |
| 7496 checkElementText( |
| 7497 library, |
| 7498 r''' |
| 7499 class C { |
| 7500 dynamic x; |
| 7501 } |
| 7502 '''); |
| 7503 } |
| 3234 } | 7504 } |
| 3235 | 7505 |
| 3236 test_function_async() { | 7506 test_function_async() { |
| 3237 checkLibrary(r''' | 7507 var library = checkLibrary(r''' |
| 3238 import 'dart:async'; | 7508 import 'dart:async'; |
| 3239 Future f() async {} | 7509 Future f() async {} |
| 3240 '''); | 7510 '''); |
| 7511 if (isStrongMode) { |
| 7512 checkElementText( |
| 7513 library, |
| 7514 r''' |
| 7515 import 'dart:async'; |
| 7516 Future<dynamic> f() async {} |
| 7517 '''); |
| 7518 } else { |
| 7519 checkElementText( |
| 7520 library, |
| 7521 r''' |
| 7522 import 'dart:async'; |
| 7523 Future<dynamic> f() async {} |
| 7524 '''); |
| 7525 } |
| 3241 } | 7526 } |
| 3242 | 7527 |
| 3243 test_function_asyncStar() { | 7528 test_function_asyncStar() { |
| 3244 checkLibrary(r''' | 7529 var library = checkLibrary(r''' |
| 3245 import 'dart:async'; | 7530 import 'dart:async'; |
| 3246 Stream f() async* {} | 7531 Stream f() async* {} |
| 3247 '''); | 7532 '''); |
| 7533 if (isStrongMode) { |
| 7534 checkElementText( |
| 7535 library, |
| 7536 r''' |
| 7537 import 'dart:async'; |
| 7538 Stream<dynamic> f() async* {} |
| 7539 '''); |
| 7540 } else { |
| 7541 checkElementText( |
| 7542 library, |
| 7543 r''' |
| 7544 import 'dart:async'; |
| 7545 Stream<dynamic> f() async* {} |
| 7546 '''); |
| 7547 } |
| 3248 } | 7548 } |
| 3249 | 7549 |
| 3250 test_function_documented() { | 7550 test_function_documented() { |
| 3251 checkLibrary(''' | 7551 var library = checkLibrary(''' |
| 3252 // Extra comment so doc comment offset != 0 | 7552 // Extra comment so doc comment offset != 0 |
| 3253 /** | 7553 /** |
| 3254 * Docs | 7554 * Docs |
| 3255 */ | 7555 */ |
| 3256 f() {}'''); | 7556 f() {}'''); |
| 7557 if (isStrongMode) { |
| 7558 checkElementText( |
| 7559 library, |
| 7560 r''' |
| 7561 dynamic f() {} |
| 7562 '''); |
| 7563 } else { |
| 7564 checkElementText( |
| 7565 library, |
| 7566 r''' |
| 7567 dynamic f() {} |
| 7568 '''); |
| 7569 } |
| 3257 } | 7570 } |
| 3258 | 7571 |
| 3259 test_function_entry_point() { | 7572 test_function_entry_point() { |
| 3260 checkLibrary('main() {}'); | 7573 var library = checkLibrary('main() {}'); |
| 7574 if (isStrongMode) { |
| 7575 checkElementText( |
| 7576 library, |
| 7577 r''' |
| 7578 dynamic main() {} |
| 7579 '''); |
| 7580 } else { |
| 7581 checkElementText( |
| 7582 library, |
| 7583 r''' |
| 7584 dynamic main() {} |
| 7585 '''); |
| 7586 } |
| 3261 } | 7587 } |
| 3262 | 7588 |
| 3263 test_function_entry_point_in_export() { | 7589 test_function_entry_point_in_export() { |
| 3264 addLibrarySource('/a.dart', 'library a; main() {}'); | 7590 addLibrarySource('/a.dart', 'library a; main() {}'); |
| 3265 checkLibrary('export "a.dart";'); | 7591 var library = checkLibrary('export "a.dart";'); |
| 7592 if (isStrongMode) { |
| 7593 checkElementText( |
| 7594 library, |
| 7595 r''' |
| 7596 export 'a.dart'; |
| 7597 '''); |
| 7598 } else { |
| 7599 checkElementText( |
| 7600 library, |
| 7601 r''' |
| 7602 export 'a.dart'; |
| 7603 '''); |
| 7604 } |
| 3266 } | 7605 } |
| 3267 | 7606 |
| 3268 test_function_entry_point_in_export_hidden() { | 7607 test_function_entry_point_in_export_hidden() { |
| 3269 addLibrarySource('/a.dart', 'library a; main() {}'); | 7608 addLibrarySource('/a.dart', 'library a; main() {}'); |
| 3270 checkLibrary('export "a.dart" hide main;'); | 7609 var library = checkLibrary('export "a.dart" hide main;'); |
| 7610 if (isStrongMode) { |
| 7611 checkElementText( |
| 7612 library, |
| 7613 r''' |
| 7614 export 'a.dart' hide main; |
| 7615 '''); |
| 7616 } else { |
| 7617 checkElementText( |
| 7618 library, |
| 7619 r''' |
| 7620 export 'a.dart' hide main; |
| 7621 '''); |
| 7622 } |
| 3271 } | 7623 } |
| 3272 | 7624 |
| 3273 test_function_entry_point_in_part() { | 7625 test_function_entry_point_in_part() { |
| 3274 addSource('/a.dart', 'part of my.lib; main() {}'); | 7626 addSource('/a.dart', 'part of my.lib; main() {}'); |
| 3275 checkLibrary('library my.lib; part "a.dart";'); | 7627 var library = checkLibrary('library my.lib; part "a.dart";'); |
| 7628 if (isStrongMode) { |
| 7629 checkElementText( |
| 7630 library, |
| 7631 r''' |
| 7632 library my.lib; |
| 7633 part 'a.dart'; |
| 7634 -------------------- |
| 7635 unit: a.dart |
| 7636 |
| 7637 dynamic main() {} |
| 7638 '''); |
| 7639 } else { |
| 7640 checkElementText( |
| 7641 library, |
| 7642 r''' |
| 7643 library my.lib; |
| 7644 part 'a.dart'; |
| 7645 -------------------- |
| 7646 unit: a.dart |
| 7647 |
| 7648 dynamic main() {} |
| 7649 '''); |
| 7650 } |
| 3276 } | 7651 } |
| 3277 | 7652 |
| 3278 test_function_external() { | 7653 test_function_external() { |
| 3279 checkLibrary('external f();'); | 7654 var library = checkLibrary('external f();'); |
| 7655 if (isStrongMode) { |
| 7656 checkElementText( |
| 7657 library, |
| 7658 r''' |
| 7659 external dynamic f() {} |
| 7660 '''); |
| 7661 } else { |
| 7662 checkElementText( |
| 7663 library, |
| 7664 r''' |
| 7665 external dynamic f() {} |
| 7666 '''); |
| 7667 } |
| 3280 } | 7668 } |
| 3281 | 7669 |
| 3282 test_function_parameter_final() { | 7670 test_function_parameter_final() { |
| 3283 checkLibrary('f(final x) {}'); | 7671 var library = checkLibrary('f(final x) {}'); |
| 7672 if (isStrongMode) { |
| 7673 checkElementText( |
| 7674 library, |
| 7675 r''' |
| 7676 dynamic f(final dynamic x) {} |
| 7677 '''); |
| 7678 } else { |
| 7679 checkElementText( |
| 7680 library, |
| 7681 r''' |
| 7682 dynamic f(final dynamic x) {} |
| 7683 '''); |
| 7684 } |
| 3284 } | 7685 } |
| 3285 | 7686 |
| 3286 test_function_parameter_kind_named() { | 7687 test_function_parameter_kind_named() { |
| 3287 checkLibrary('f({x}) {}'); | 7688 var library = checkLibrary('f({x}) {}'); |
| 7689 if (isStrongMode) { |
| 7690 checkElementText( |
| 7691 library, |
| 7692 r''' |
| 7693 dynamic f({dynamic x}) {} |
| 7694 '''); |
| 7695 } else { |
| 7696 checkElementText( |
| 7697 library, |
| 7698 r''' |
| 7699 dynamic f({dynamic x}) {} |
| 7700 '''); |
| 7701 } |
| 3288 } | 7702 } |
| 3289 | 7703 |
| 3290 test_function_parameter_kind_positional() { | 7704 test_function_parameter_kind_positional() { |
| 3291 checkLibrary('f([x]) {}'); | 7705 var library = checkLibrary('f([x]) {}'); |
| 7706 if (isStrongMode) { |
| 7707 checkElementText( |
| 7708 library, |
| 7709 r''' |
| 7710 dynamic f([dynamic x]) {} |
| 7711 '''); |
| 7712 } else { |
| 7713 checkElementText( |
| 7714 library, |
| 7715 r''' |
| 7716 dynamic f([dynamic x]) {} |
| 7717 '''); |
| 7718 } |
| 3292 } | 7719 } |
| 3293 | 7720 |
| 3294 test_function_parameter_kind_required() { | 7721 test_function_parameter_kind_required() { |
| 3295 checkLibrary('f(x) {}'); | 7722 var library = checkLibrary('f(x) {}'); |
| 7723 if (isStrongMode) { |
| 7724 checkElementText( |
| 7725 library, |
| 7726 r''' |
| 7727 dynamic f(dynamic x) {} |
| 7728 '''); |
| 7729 } else { |
| 7730 checkElementText( |
| 7731 library, |
| 7732 r''' |
| 7733 dynamic f(dynamic x) {} |
| 7734 '''); |
| 7735 } |
| 3296 } | 7736 } |
| 3297 | 7737 |
| 3298 test_function_parameter_parameters() { | 7738 test_function_parameter_parameters() { |
| 3299 checkLibrary('f(g(x, y)) {}'); | 7739 var library = checkLibrary('f(g(x, y)) {}'); |
| 7740 if (isStrongMode) { |
| 7741 checkElementText( |
| 7742 library, |
| 7743 r''' |
| 7744 dynamic f((dynamic, dynamic) → dynamic g) {} |
| 7745 '''); |
| 7746 } else { |
| 7747 checkElementText( |
| 7748 library, |
| 7749 r''' |
| 7750 dynamic f((dynamic, dynamic) → dynamic g) {} |
| 7751 '''); |
| 7752 } |
| 3300 } | 7753 } |
| 3301 | 7754 |
| 3302 test_function_parameter_return_type() { | 7755 test_function_parameter_return_type() { |
| 3303 checkLibrary('f(int g()) {}'); | 7756 var library = checkLibrary('f(int g()) {}'); |
| 7757 if (isStrongMode) { |
| 7758 checkElementText( |
| 7759 library, |
| 7760 r''' |
| 7761 dynamic f(() → int g) {} |
| 7762 '''); |
| 7763 } else { |
| 7764 checkElementText( |
| 7765 library, |
| 7766 r''' |
| 7767 dynamic f(() → int g) {} |
| 7768 '''); |
| 7769 } |
| 3304 } | 7770 } |
| 3305 | 7771 |
| 3306 test_function_parameter_return_type_void() { | 7772 test_function_parameter_return_type_void() { |
| 3307 checkLibrary('f(void g()) {}'); | 7773 var library = checkLibrary('f(void g()) {}'); |
| 7774 if (isStrongMode) { |
| 7775 checkElementText( |
| 7776 library, |
| 7777 r''' |
| 7778 dynamic f(() → void g) {} |
| 7779 '''); |
| 7780 } else { |
| 7781 checkElementText( |
| 7782 library, |
| 7783 r''' |
| 7784 dynamic f(() → void g) {} |
| 7785 '''); |
| 7786 } |
| 3308 } | 7787 } |
| 3309 | 7788 |
| 3310 test_function_parameter_type() { | 7789 test_function_parameter_type() { |
| 3311 checkLibrary('f(int i) {}'); | 7790 var library = checkLibrary('f(int i) {}'); |
| 7791 if (isStrongMode) { |
| 7792 checkElementText( |
| 7793 library, |
| 7794 r''' |
| 7795 dynamic f(int i) {} |
| 7796 '''); |
| 7797 } else { |
| 7798 checkElementText( |
| 7799 library, |
| 7800 r''' |
| 7801 dynamic f(int i) {} |
| 7802 '''); |
| 7803 } |
| 3312 } | 7804 } |
| 3313 | 7805 |
| 3314 test_function_parameters() { | 7806 test_function_parameters() { |
| 3315 checkLibrary('f(x, y) {}'); | 7807 var library = checkLibrary('f(x, y) {}'); |
| 7808 if (isStrongMode) { |
| 7809 checkElementText( |
| 7810 library, |
| 7811 r''' |
| 7812 dynamic f(dynamic x, dynamic y) {} |
| 7813 '''); |
| 7814 } else { |
| 7815 checkElementText( |
| 7816 library, |
| 7817 r''' |
| 7818 dynamic f(dynamic x, dynamic y) {} |
| 7819 '''); |
| 7820 } |
| 3316 } | 7821 } |
| 3317 | 7822 |
| 3318 test_function_return_type() { | 7823 test_function_return_type() { |
| 3319 checkLibrary('int f() => null;'); | 7824 var library = checkLibrary('int f() => null;'); |
| 7825 if (isStrongMode) { |
| 7826 checkElementText( |
| 7827 library, |
| 7828 r''' |
| 7829 int f() {} |
| 7830 '''); |
| 7831 } else { |
| 7832 checkElementText( |
| 7833 library, |
| 7834 r''' |
| 7835 int f() {} |
| 7836 '''); |
| 7837 } |
| 3320 } | 7838 } |
| 3321 | 7839 |
| 3322 test_function_return_type_implicit() { | 7840 test_function_return_type_implicit() { |
| 3323 checkLibrary('f() => null;'); | 7841 var library = checkLibrary('f() => null;'); |
| 7842 if (isStrongMode) { |
| 7843 checkElementText( |
| 7844 library, |
| 7845 r''' |
| 7846 dynamic f() {} |
| 7847 '''); |
| 7848 } else { |
| 7849 checkElementText( |
| 7850 library, |
| 7851 r''' |
| 7852 dynamic f() {} |
| 7853 '''); |
| 7854 } |
| 3324 } | 7855 } |
| 3325 | 7856 |
| 3326 test_function_return_type_void() { | 7857 test_function_return_type_void() { |
| 3327 checkLibrary('void f() {}'); | 7858 var library = checkLibrary('void f() {}'); |
| 7859 if (isStrongMode) { |
| 7860 checkElementText( |
| 7861 library, |
| 7862 r''' |
| 7863 void f() {} |
| 7864 '''); |
| 7865 } else { |
| 7866 checkElementText( |
| 7867 library, |
| 7868 r''' |
| 7869 void f() {} |
| 7870 '''); |
| 7871 } |
| 3328 } | 7872 } |
| 3329 | 7873 |
| 3330 test_function_type_parameter() { | 7874 test_function_type_parameter() { |
| 3331 prepareAnalysisContext(createOptions()); | 7875 prepareAnalysisContext(createOptions()); |
| 3332 checkLibrary('T f<T, U>(U u) => null;'); | 7876 var library = checkLibrary('T f<T, U>(U u) => null;'); |
| 7877 if (isStrongMode) { |
| 7878 checkElementText( |
| 7879 library, |
| 7880 r''' |
| 7881 T f<T, U>(U u) {} |
| 7882 '''); |
| 7883 } else { |
| 7884 checkElementText( |
| 7885 library, |
| 7886 r''' |
| 7887 T f<T, U>(U u) {} |
| 7888 '''); |
| 7889 } |
| 3333 } | 7890 } |
| 3334 | 7891 |
| 3335 test_function_type_parameter_with_function_typed_parameter() { | 7892 test_function_type_parameter_with_function_typed_parameter() { |
| 3336 prepareAnalysisContext(createOptions()); | 7893 prepareAnalysisContext(createOptions()); |
| 3337 checkLibrary('void f<T, U>(T x(U u)) {}'); | 7894 var library = checkLibrary('void f<T, U>(T x(U u)) {}'); |
| 7895 if (isStrongMode) { |
| 7896 checkElementText( |
| 7897 library, |
| 7898 r''' |
| 7899 void f<T, U>((U) → T x) {} |
| 7900 '''); |
| 7901 } else { |
| 7902 checkElementText( |
| 7903 library, |
| 7904 r''' |
| 7905 void f<T, U>((U) → T x) {} |
| 7906 '''); |
| 7907 } |
| 3338 } | 7908 } |
| 3339 | 7909 |
| 3340 test_functions() { | 7910 test_functions() { |
| 3341 checkLibrary('f() {} g() {}'); | 7911 var library = checkLibrary('f() {} g() {}'); |
| 7912 if (isStrongMode) { |
| 7913 checkElementText( |
| 7914 library, |
| 7915 r''' |
| 7916 dynamic f() {} |
| 7917 dynamic g() {} |
| 7918 '''); |
| 7919 } else { |
| 7920 checkElementText( |
| 7921 library, |
| 7922 r''' |
| 7923 dynamic f() {} |
| 7924 dynamic g() {} |
| 7925 '''); |
| 7926 } |
| 3342 } | 7927 } |
| 3343 | 7928 |
| 3344 test_futureOr() { | 7929 test_futureOr() { |
| 3345 var library = checkLibrary('import "dart:async"; FutureOr<int> x;'); | 7930 var library = checkLibrary('import "dart:async"; FutureOr<int> x;'); |
| 7931 if (isStrongMode) { |
| 7932 checkElementText( |
| 7933 library, |
| 7934 r''' |
| 7935 import 'dart:async'; |
| 7936 FutureOr<int> x; |
| 7937 '''); |
| 7938 } else { |
| 7939 checkElementText( |
| 7940 library, |
| 7941 r''' |
| 7942 import 'dart:async'; |
| 7943 dynamic x; |
| 7944 '''); |
| 7945 } |
| 3346 var variables = library.definingCompilationUnit.topLevelVariables; | 7946 var variables = library.definingCompilationUnit.topLevelVariables; |
| 3347 expect(variables, hasLength(1)); | 7947 expect(variables, hasLength(1)); |
| 3348 if (createOptions().strongMode) { | 7948 if (createOptions().strongMode) { |
| 3349 expect(variables[0].type.toString(), 'FutureOr<int>'); | 7949 expect(variables[0].type.toString(), 'FutureOr<int>'); |
| 3350 } else { | 7950 } else { |
| 3351 expect(variables[0].type.toString(), 'dynamic'); | 7951 expect(variables[0].type.toString(), 'dynamic'); |
| 3352 } | 7952 } |
| 3353 } | 7953 } |
| 3354 | 7954 |
| 3355 test_futureOr_const() { | 7955 test_futureOr_const() { |
| 3356 var library = checkLibrary('import "dart:async"; const x = FutureOr;'); | 7956 var library = checkLibrary('import "dart:async"; const x = FutureOr;'); |
| 7957 if (isStrongMode) { |
| 7958 checkElementText( |
| 7959 library, |
| 7960 r''' |
| 7961 import 'dart:async'; |
| 7962 const Type x = FutureOr; |
| 7963 '''); |
| 7964 } else { |
| 7965 checkElementText( |
| 7966 library, |
| 7967 r''' |
| 7968 import 'dart:async'; |
| 7969 const dynamic x = FutureOr; |
| 7970 '''); |
| 7971 } |
| 3357 var variables = library.definingCompilationUnit.topLevelVariables; | 7972 var variables = library.definingCompilationUnit.topLevelVariables; |
| 3358 expect(variables, hasLength(1)); | 7973 expect(variables, hasLength(1)); |
| 3359 var x = variables[0] as ConstTopLevelVariableElementImpl; | 7974 var x = variables[0] as ConstTopLevelVariableElementImpl; |
| 3360 if (createOptions().strongMode) { | 7975 if (createOptions().strongMode) { |
| 3361 expect(x.type.toString(), 'Type'); | 7976 expect(x.type.toString(), 'Type'); |
| 3362 } else { | 7977 } else { |
| 3363 expect(x.type.toString(), 'dynamic'); | 7978 expect(x.type.toString(), 'dynamic'); |
| 3364 } | 7979 } |
| 3365 expect(x.constantInitializer.toString(), 'FutureOr'); | 7980 expect(x.constantInitializer.toString(), 'FutureOr'); |
| 3366 } | 7981 } |
| 3367 | 7982 |
| 3368 test_futureOr_inferred() { | 7983 test_futureOr_inferred() { |
| 3369 var library = checkLibrary(''' | 7984 var library = checkLibrary(''' |
| 3370 import "dart:async"; | 7985 import "dart:async"; |
| 3371 FutureOr<int> f() => null; | 7986 FutureOr<int> f() => null; |
| 3372 var x = f(); | 7987 var x = f(); |
| 3373 var y = x.then((z) => z.asDouble()); | 7988 var y = x.then((z) => z.asDouble()); |
| 3374 '''); | 7989 '''); |
| 7990 if (isStrongMode) { |
| 7991 checkElementText( |
| 7992 library, |
| 7993 r''' |
| 7994 import 'dart:async'; |
| 7995 FutureOr<int> x; |
| 7996 dynamic y; |
| 7997 FutureOr<int> f() {} |
| 7998 '''); |
| 7999 } else { |
| 8000 checkElementText( |
| 8001 library, |
| 8002 r''' |
| 8003 import 'dart:async'; |
| 8004 dynamic x; |
| 8005 dynamic y; |
| 8006 dynamic f() {} |
| 8007 '''); |
| 8008 } |
| 3375 var variables = library.definingCompilationUnit.topLevelVariables; | 8009 var variables = library.definingCompilationUnit.topLevelVariables; |
| 3376 expect(variables, hasLength(2)); | 8010 expect(variables, hasLength(2)); |
| 3377 var x = variables[0]; | 8011 var x = variables[0]; |
| 3378 expect(x.name, 'x'); | 8012 expect(x.name, 'x'); |
| 3379 var y = variables[1]; | 8013 var y = variables[1]; |
| 3380 expect(y.name, 'y'); | 8014 expect(y.name, 'y'); |
| 3381 if (createOptions().strongMode) { | 8015 if (createOptions().strongMode) { |
| 3382 expect(x.type.toString(), 'FutureOr<int>'); | 8016 expect(x.type.toString(), 'FutureOr<int>'); |
| 3383 expect(y.type.toString(), 'dynamic'); | 8017 expect(y.type.toString(), 'dynamic'); |
| 3384 } else { | 8018 } else { |
| 3385 expect(x.type.toString(), 'dynamic'); | 8019 expect(x.type.toString(), 'dynamic'); |
| 3386 expect(y.type.toString(), 'dynamic'); | 8020 expect(y.type.toString(), 'dynamic'); |
| 3387 } | 8021 } |
| 3388 } | 8022 } |
| 3389 | 8023 |
| 3390 test_generic_gClass_gMethodStatic() { | 8024 test_generic_gClass_gMethodStatic() { |
| 3391 prepareAnalysisContext(createOptions()); | 8025 prepareAnalysisContext(createOptions()); |
| 3392 checkLibrary(''' | 8026 var library = checkLibrary(''' |
| 3393 class C<T, U> { | 8027 class C<T, U> { |
| 3394 static void m<V, W>(V v, W w) { | 8028 static void m<V, W>(V v, W w) { |
| 3395 void f<X, Y>(V v, W w, X x, Y y) { | 8029 void f<X, Y>(V v, W w, X x, Y y) { |
| 3396 } | 8030 } |
| 3397 } | 8031 } |
| 3398 } | 8032 } |
| 3399 '''); | 8033 '''); |
| 8034 if (isStrongMode) { |
| 8035 checkElementText( |
| 8036 library, |
| 8037 r''' |
| 8038 class C<T, U> { |
| 8039 static void m<V, W>(V v, W w) {} |
| 8040 } |
| 8041 '''); |
| 8042 } else { |
| 8043 checkElementText( |
| 8044 library, |
| 8045 r''' |
| 8046 class C<T, U> { |
| 8047 static void m<V, W>(V v, W w) {} |
| 8048 } |
| 8049 '''); |
| 8050 } |
| 3400 } | 8051 } |
| 3401 | 8052 |
| 3402 test_getElement_constructor_named() { | 8053 test_getElement_constructor_named() { |
| 3403 String text = 'class C { C.named(); }'; | 8054 String text = 'class C { C.named(); }'; |
| 3404 Source source = addLibrarySource('/test.dart', text); | 8055 Source source = addLibrarySource('/test.dart', text); |
| 3405 ConstructorElement original = context | 8056 ConstructorElement original = context |
| 3406 .computeLibraryElement(source) | 8057 .computeLibraryElement(source) |
| 3407 .getType('C') | 8058 .getType('C') |
| 3408 .getNamedConstructor('named'); | 8059 .getNamedConstructor('named'); |
| 3409 expect(original, isNotNull); | 8060 expect(original, isNotNull); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3475 String text = 'class C { f() {} }'; | 8126 String text = 'class C { f() {} }'; |
| 3476 Source source = addLibrarySource('/test.dart', text); | 8127 Source source = addLibrarySource('/test.dart', text); |
| 3477 CompilationUnitElement original = | 8128 CompilationUnitElement original = |
| 3478 context.computeLibraryElement(source).definingCompilationUnit; | 8129 context.computeLibraryElement(source).definingCompilationUnit; |
| 3479 expect(original, isNotNull); | 8130 expect(original, isNotNull); |
| 3480 CompilationUnitElement resynthesized = validateGetElement(text, original); | 8131 CompilationUnitElement resynthesized = validateGetElement(text, original); |
| 3481 compareCompilationUnitElements(resynthesized, original); | 8132 compareCompilationUnitElements(resynthesized, original); |
| 3482 } | 8133 } |
| 3483 | 8134 |
| 3484 test_getter_documented() { | 8135 test_getter_documented() { |
| 3485 checkLibrary(''' | 8136 var library = checkLibrary(''' |
| 3486 // Extra comment so doc comment offset != 0 | 8137 // Extra comment so doc comment offset != 0 |
| 3487 /** | 8138 /** |
| 3488 * Docs | 8139 * Docs |
| 3489 */ | 8140 */ |
| 3490 get x => null;'''); | 8141 get x => null;'''); |
| 8142 if (isStrongMode) { |
| 8143 checkElementText( |
| 8144 library, |
| 8145 r''' |
| 8146 /** |
| 8147 * Docs |
| 8148 */ |
| 8149 dynamic get x {} |
| 8150 '''); |
| 8151 } else { |
| 8152 checkElementText( |
| 8153 library, |
| 8154 r''' |
| 8155 /** |
| 8156 * Docs |
| 8157 */ |
| 8158 dynamic get x {} |
| 8159 '''); |
| 8160 } |
| 3491 } | 8161 } |
| 3492 | 8162 |
| 3493 test_getter_external() { | 8163 test_getter_external() { |
| 3494 checkLibrary('external int get x;'); | 8164 var library = checkLibrary('external int get x;'); |
| 8165 if (isStrongMode) { |
| 8166 checkElementText( |
| 8167 library, |
| 8168 r''' |
| 8169 external int get x {} |
| 8170 '''); |
| 8171 } else { |
| 8172 checkElementText( |
| 8173 library, |
| 8174 r''' |
| 8175 external int get x {} |
| 8176 '''); |
| 8177 } |
| 3495 } | 8178 } |
| 3496 | 8179 |
| 3497 test_getter_inferred_type_nonStatic_implicit_return() { | 8180 test_getter_inferred_type_nonStatic_implicit_return() { |
| 3498 checkLibrary( | 8181 var library = checkLibrary( |
| 3499 'class C extends D { get f => null; } abstract class D { int get f; }'); | 8182 'class C extends D { get f => null; } abstract class D { int get f; }'); |
| 8183 if (isStrongMode) { |
| 8184 checkElementText( |
| 8185 library, |
| 8186 r''' |
| 8187 class C extends D { |
| 8188 int get f {} |
| 8189 } |
| 8190 abstract class D { |
| 8191 int get f; |
| 8192 } |
| 8193 '''); |
| 8194 } else { |
| 8195 checkElementText( |
| 8196 library, |
| 8197 r''' |
| 8198 class C extends D { |
| 8199 dynamic get f {} |
| 8200 } |
| 8201 abstract class D { |
| 8202 int get f; |
| 8203 } |
| 8204 '''); |
| 8205 } |
| 3500 } | 8206 } |
| 3501 | 8207 |
| 3502 test_getters() { | 8208 test_getters() { |
| 3503 checkLibrary('int get x => null; get y => null;'); | 8209 var library = checkLibrary('int get x => null; get y => null;'); |
| 8210 if (isStrongMode) { |
| 8211 checkElementText( |
| 8212 library, |
| 8213 r''' |
| 8214 int get x {} |
| 8215 dynamic get y {} |
| 8216 '''); |
| 8217 } else { |
| 8218 checkElementText( |
| 8219 library, |
| 8220 r''' |
| 8221 int get x {} |
| 8222 dynamic get y {} |
| 8223 '''); |
| 8224 } |
| 3504 } | 8225 } |
| 3505 | 8226 |
| 3506 test_implicitTopLevelVariable_getterFirst() { | 8227 test_implicitTopLevelVariable_getterFirst() { |
| 3507 checkLibrary('int get x => 0; void set x(int value) {}'); | 8228 var library = checkLibrary('int get x => 0; void set x(int value) {}'); |
| 8229 if (isStrongMode) { |
| 8230 checkElementText( |
| 8231 library, |
| 8232 r''' |
| 8233 int get x {} |
| 8234 void set x(int value) {} |
| 8235 '''); |
| 8236 } else { |
| 8237 checkElementText( |
| 8238 library, |
| 8239 r''' |
| 8240 int get x {} |
| 8241 void set x(int value) {} |
| 8242 '''); |
| 8243 } |
| 3508 } | 8244 } |
| 3509 | 8245 |
| 3510 test_implicitTopLevelVariable_setterFirst() { | 8246 test_implicitTopLevelVariable_setterFirst() { |
| 3511 checkLibrary('void set x(int value) {} int get x => 0;'); | 8247 var library = checkLibrary('void set x(int value) {} int get x => 0;'); |
| 8248 if (isStrongMode) { |
| 8249 checkElementText( |
| 8250 library, |
| 8251 r''' |
| 8252 void set x(int value) {} |
| 8253 int get x {} |
| 8254 '''); |
| 8255 } else { |
| 8256 checkElementText( |
| 8257 library, |
| 8258 r''' |
| 8259 void set x(int value) {} |
| 8260 int get x {} |
| 8261 '''); |
| 8262 } |
| 3512 } | 8263 } |
| 3513 | 8264 |
| 3514 test_import_configurations_useDefault() { | 8265 test_import_configurations_useDefault() { |
| 3515 context.declaredVariables.define('dart.library.io', 'false'); | 8266 context.declaredVariables.define('dart.library.io', 'false'); |
| 3516 addLibrarySource('/foo.dart', 'class A {}'); | 8267 addLibrarySource('/foo.dart', 'class A {}'); |
| 3517 addLibrarySource('/foo_io.dart', 'class A {}'); | 8268 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3518 addLibrarySource('/foo_html.dart', 'class A {}'); | 8269 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3519 var library = checkLibrary(r''' | 8270 var library = checkLibrary(r''' |
| 3520 import 'foo.dart' | 8271 import 'foo.dart' |
| 3521 if (dart.library.io) 'foo_io.dart' | 8272 if (dart.library.io) 'foo_io.dart' |
| 3522 if (dart.library.html) 'foo_html.dart'; | 8273 if (dart.library.html) 'foo_html.dart'; |
| 3523 | 8274 |
| 3524 class B extends A {} | 8275 class B extends A {} |
| 3525 '''); | 8276 '''); |
| 8277 if (isStrongMode) { |
| 8278 checkElementText( |
| 8279 library, |
| 8280 r''' |
| 8281 import 'foo.dart'; |
| 8282 class B extends A { |
| 8283 } |
| 8284 '''); |
| 8285 } else { |
| 8286 checkElementText( |
| 8287 library, |
| 8288 r''' |
| 8289 import 'foo.dart'; |
| 8290 class B extends A { |
| 8291 } |
| 8292 '''); |
| 8293 } |
| 3526 var typeA = library.definingCompilationUnit.getType('B').supertype; | 8294 var typeA = library.definingCompilationUnit.getType('B').supertype; |
| 3527 expect(typeA.element.source.shortName, 'foo.dart'); | 8295 expect(typeA.element.source.shortName, 'foo.dart'); |
| 3528 } | 8296 } |
| 3529 | 8297 |
| 3530 test_import_configurations_useFirst() { | 8298 test_import_configurations_useFirst() { |
| 3531 context.declaredVariables.define('dart.library.io', 'true'); | 8299 context.declaredVariables.define('dart.library.io', 'true'); |
| 3532 context.declaredVariables.define('dart.library.html', 'true'); | 8300 context.declaredVariables.define('dart.library.html', 'true'); |
| 3533 addLibrarySource('/foo.dart', 'class A {}'); | 8301 addLibrarySource('/foo.dart', 'class A {}'); |
| 3534 addLibrarySource('/foo_io.dart', 'class A {}'); | 8302 addLibrarySource('/foo_io.dart', 'class A {}'); |
| 3535 addLibrarySource('/foo_html.dart', 'class A {}'); | 8303 addLibrarySource('/foo_html.dart', 'class A {}'); |
| 3536 var library = checkLibrary(r''' | 8304 var library = checkLibrary(r''' |
| 3537 import 'foo.dart' | 8305 import 'foo.dart' |
| 3538 if (dart.library.io) 'foo_io.dart' | 8306 if (dart.library.io) 'foo_io.dart' |
| 3539 if (dart.library.html) 'foo_html.dart'; | 8307 if (dart.library.html) 'foo_html.dart'; |
| 3540 | 8308 |
| 3541 class B extends A {} | 8309 class B extends A {} |
| 3542 '''); | 8310 '''); |
| 8311 if (isStrongMode) { |
| 8312 checkElementText( |
| 8313 library, |
| 8314 r''' |
| 8315 import 'foo_io.dart'; |
| 8316 class B extends A { |
| 8317 } |
| 8318 '''); |
| 8319 } else { |
| 8320 checkElementText( |
| 8321 library, |
| 8322 r''' |
| 8323 import 'foo_io.dart'; |
| 8324 class B extends A { |
| 8325 } |
| 8326 '''); |
| 8327 } |
| 3543 var typeA = library.definingCompilationUnit.getType('B').supertype; | 8328 var typeA = library.definingCompilationUnit.getType('B').supertype; |
| 3544 expect(typeA.element.source.shortName, 'foo_io.dart'); | 8329 expect(typeA.element.source.shortName, 'foo_io.dart'); |
| 3545 } | 8330 } |
| 3546 | 8331 |
| 3547 test_import_deferred() { | 8332 test_import_deferred() { |
| 3548 addLibrarySource('/a.dart', 'f() {}'); | 8333 addLibrarySource('/a.dart', 'f() {}'); |
| 3549 checkLibrary('import "a.dart" deferred as p; main() { p.f(); }'); | 8334 var library = |
| 8335 checkLibrary('import "a.dart" deferred as p; main() { p.f(); }'); |
| 8336 if (isStrongMode) { |
| 8337 checkElementText( |
| 8338 library, |
| 8339 r''' |
| 8340 import 'a.dart' deferred as p; |
| 8341 dynamic main() {} |
| 8342 '''); |
| 8343 } else { |
| 8344 checkElementText( |
| 8345 library, |
| 8346 r''' |
| 8347 import 'a.dart' deferred as p; |
| 8348 dynamic main() {} |
| 8349 '''); |
| 8350 } |
| 3550 } | 8351 } |
| 3551 | 8352 |
| 3552 test_import_hide() { | 8353 test_import_hide() { |
| 3553 addLibrary('dart:async'); | 8354 addLibrary('dart:async'); |
| 3554 checkLibrary('import "dart:async" hide Stream, Completer; Future f;'); | 8355 var library = |
| 8356 checkLibrary('import "dart:async" hide Stream, Completer; Future f;'); |
| 8357 if (isStrongMode) { |
| 8358 checkElementText( |
| 8359 library, |
| 8360 r''' |
| 8361 import 'dart:async' hide Stream, Completer; |
| 8362 Future<dynamic> f; |
| 8363 '''); |
| 8364 } else { |
| 8365 checkElementText( |
| 8366 library, |
| 8367 r''' |
| 8368 import 'dart:async' hide Stream, Completer; |
| 8369 Future<dynamic> f; |
| 8370 '''); |
| 8371 } |
| 3555 } | 8372 } |
| 3556 | 8373 |
| 3557 test_import_multiple_combinators() { | 8374 test_import_multiple_combinators() { |
| 3558 addLibrary('dart:async'); | 8375 addLibrary('dart:async'); |
| 3559 checkLibrary('import "dart:async" hide Stream show Future; Future f;'); | 8376 var library = |
| 8377 checkLibrary('import "dart:async" hide Stream show Future; Future f;'); |
| 8378 if (isStrongMode) { |
| 8379 checkElementText( |
| 8380 library, |
| 8381 r''' |
| 8382 import 'dart:async' hide Stream show Future; |
| 8383 Future<dynamic> f; |
| 8384 '''); |
| 8385 } else { |
| 8386 checkElementText( |
| 8387 library, |
| 8388 r''' |
| 8389 import 'dart:async' hide Stream show Future; |
| 8390 Future<dynamic> f; |
| 8391 '''); |
| 8392 } |
| 3560 } | 8393 } |
| 3561 | 8394 |
| 3562 test_import_prefixed() { | 8395 test_import_prefixed() { |
| 3563 addLibrarySource('/a.dart', 'library a; class C {}'); | 8396 addLibrarySource('/a.dart', 'library a; class C {}'); |
| 3564 checkLibrary('import "a.dart" as a; a.C c;'); | 8397 var library = checkLibrary('import "a.dart" as a; a.C c;'); |
| 8398 if (isStrongMode) { |
| 8399 checkElementText( |
| 8400 library, |
| 8401 r''' |
| 8402 import 'a.dart' as a; |
| 8403 C c; |
| 8404 '''); |
| 8405 } else { |
| 8406 checkElementText( |
| 8407 library, |
| 8408 r''' |
| 8409 import 'a.dart' as a; |
| 8410 C c; |
| 8411 '''); |
| 8412 } |
| 3565 } | 8413 } |
| 3566 | 8414 |
| 3567 test_import_self() { | 8415 test_import_self() { |
| 3568 LibraryElementImpl resynthesized = checkLibrary(''' | 8416 LibraryElementImpl resynthesized = checkLibrary(''' |
| 3569 import 'test.dart' as p; | 8417 import 'test.dart' as p; |
| 3570 class C {} | 8418 class C {} |
| 3571 class D extends p.C {} // Prevent "unused import" warning | 8419 class D extends p.C {} // Prevent "unused import" warning |
| 3572 '''); | 8420 '''); |
| 3573 expect(resynthesized.imports, hasLength(2)); | 8421 expect(resynthesized.imports, hasLength(2)); |
| 3574 expect(resynthesized.imports[0].importedLibrary.location, | 8422 expect(resynthesized.imports[0].importedLibrary.location, |
| 3575 resynthesized.location); | 8423 resynthesized.location); |
| 3576 expect(resynthesized.imports[1].importedLibrary.isDartCore, true); | 8424 expect(resynthesized.imports[1].importedLibrary.isDartCore, true); |
| 8425 if (isStrongMode) { |
| 8426 checkElementText( |
| 8427 resynthesized, |
| 8428 r''' |
| 8429 import 'test.dart' as p; |
| 8430 class C { |
| 8431 } |
| 8432 class D extends C { |
| 8433 } |
| 8434 '''); |
| 8435 } else { |
| 8436 checkElementText( |
| 8437 resynthesized, |
| 8438 r''' |
| 8439 import 'test.dart' as p; |
| 8440 class C { |
| 8441 } |
| 8442 class D extends C { |
| 8443 } |
| 8444 '''); |
| 8445 } |
| 3577 } | 8446 } |
| 3578 | 8447 |
| 3579 test_import_short_absolute() { | 8448 test_import_short_absolute() { |
| 3580 testFile = '/my/project/bin/test.dart'; | 8449 testFile = '/my/project/bin/test.dart'; |
| 3581 // Note: "/a.dart" resolves differently on Windows vs. Posix. | 8450 // Note: "/a.dart" resolves differently on Windows vs. Posix. |
| 3582 var destinationPath = | 8451 var destinationPath = |
| 3583 resourceProvider.pathContext.fromUri(Uri.parse('/a.dart')); | 8452 resourceProvider.pathContext.fromUri(Uri.parse('/a.dart')); |
| 3584 addLibrarySource(destinationPath, 'class C {}'); | 8453 addLibrarySource(destinationPath, 'class C {}'); |
| 3585 checkLibrary('import "/a.dart"; C c;'); | 8454 var library = checkLibrary('import "/a.dart"; C c;'); |
| 8455 if (isStrongMode) { |
| 8456 checkElementText( |
| 8457 library, |
| 8458 r''' |
| 8459 import '/a.dart'; |
| 8460 C c; |
| 8461 '''); |
| 8462 } else { |
| 8463 checkElementText( |
| 8464 library, |
| 8465 r''' |
| 8466 import '/a.dart'; |
| 8467 C c; |
| 8468 '''); |
| 8469 } |
| 3586 } | 8470 } |
| 3587 | 8471 |
| 3588 test_import_show() { | 8472 test_import_show() { |
| 3589 addLibrary('dart:async'); | 8473 addLibrary('dart:async'); |
| 3590 checkLibrary(''' | 8474 var library = checkLibrary(''' |
| 3591 import "dart:async" show Future, Stream; | 8475 import "dart:async" show Future, Stream; |
| 3592 Future f; | 8476 Future f; |
| 3593 Stream s; | 8477 Stream s; |
| 3594 '''); | 8478 '''); |
| 8479 if (isStrongMode) { |
| 8480 checkElementText( |
| 8481 library, |
| 8482 r''' |
| 8483 import 'dart:async' show Future, Stream; |
| 8484 Future<dynamic> f; |
| 8485 Stream<dynamic> s; |
| 8486 '''); |
| 8487 } else { |
| 8488 checkElementText( |
| 8489 library, |
| 8490 r''' |
| 8491 import 'dart:async' show Future, Stream; |
| 8492 Future<dynamic> f; |
| 8493 Stream<dynamic> s; |
| 8494 '''); |
| 8495 } |
| 3595 } | 8496 } |
| 3596 | 8497 |
| 3597 test_imports() { | 8498 test_imports() { |
| 3598 addLibrarySource('/a.dart', 'library a; class C {}'); | 8499 addLibrarySource('/a.dart', 'library a; class C {}'); |
| 3599 addLibrarySource('/b.dart', 'library b; class D {}'); | 8500 addLibrarySource('/b.dart', 'library b; class D {}'); |
| 3600 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); | 8501 var library = checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); |
| 8502 if (isStrongMode) { |
| 8503 checkElementText( |
| 8504 library, |
| 8505 r''' |
| 8506 import 'a.dart'; |
| 8507 import 'b.dart'; |
| 8508 C c; |
| 8509 D d; |
| 8510 '''); |
| 8511 } else { |
| 8512 checkElementText( |
| 8513 library, |
| 8514 r''' |
| 8515 import 'a.dart'; |
| 8516 import 'b.dart'; |
| 8517 C c; |
| 8518 D d; |
| 8519 '''); |
| 8520 } |
| 3601 } | 8521 } |
| 3602 | 8522 |
| 3603 test_inferred_function_type_for_variable_in_generic_function() { | 8523 test_inferred_function_type_for_variable_in_generic_function() { |
| 3604 // In the code below, `x` has an inferred type of `() => int`, with 2 | 8524 // In the code below, `x` has an inferred type of `() => int`, with 2 |
| 3605 // (unused) type parameters from the enclosing top level function. | 8525 // (unused) type parameters from the enclosing top level function. |
| 3606 checkLibrary(''' | 8526 var library = checkLibrary(''' |
| 3607 f<U, V>() { | 8527 f<U, V>() { |
| 3608 var x = () => 0; | 8528 var x = () => 0; |
| 3609 } | 8529 } |
| 3610 '''); | 8530 '''); |
| 8531 if (isStrongMode) { |
| 8532 checkElementText( |
| 8533 library, |
| 8534 r''' |
| 8535 dynamic f<U, V>() {} |
| 8536 '''); |
| 8537 } else { |
| 8538 checkElementText( |
| 8539 library, |
| 8540 r''' |
| 8541 dynamic f<U, V>() {} |
| 8542 '''); |
| 8543 } |
| 3611 } | 8544 } |
| 3612 | 8545 |
| 3613 test_inferred_function_type_in_generic_class_constructor() { | 8546 test_inferred_function_type_in_generic_class_constructor() { |
| 3614 // In the code below, `() => () => 0` has an inferred return type of | 8547 // In the code below, `() => () => 0` has an inferred return type of |
| 3615 // `() => int`, with 2 (unused) type parameters from the enclosing class. | 8548 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 3616 checkLibrary(''' | 8549 var library = checkLibrary(''' |
| 3617 class C<U, V> { | 8550 class C<U, V> { |
| 3618 final x; | 8551 final x; |
| 3619 C() : x = (() => () => 0); | 8552 C() : x = (() => () => 0); |
| 3620 } | 8553 } |
| 3621 '''); | 8554 '''); |
| 8555 if (isStrongMode) { |
| 8556 checkElementText( |
| 8557 library, |
| 8558 r''' |
| 8559 class C<U, V> { |
| 8560 final dynamic x; |
| 8561 C(); |
| 8562 } |
| 8563 '''); |
| 8564 } else { |
| 8565 checkElementText( |
| 8566 library, |
| 8567 r''' |
| 8568 class C<U, V> { |
| 8569 final dynamic x; |
| 8570 C(); |
| 8571 } |
| 8572 '''); |
| 8573 } |
| 3622 } | 8574 } |
| 3623 | 8575 |
| 3624 test_inferred_function_type_in_generic_class_getter() { | 8576 test_inferred_function_type_in_generic_class_getter() { |
| 3625 // In the code below, `() => () => 0` has an inferred return type of | 8577 // In the code below, `() => () => 0` has an inferred return type of |
| 3626 // `() => int`, with 2 (unused) type parameters from the enclosing class. | 8578 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 3627 checkLibrary(''' | 8579 var library = checkLibrary(''' |
| 3628 class C<U, V> { | 8580 class C<U, V> { |
| 3629 get x => () => () => 0; | 8581 get x => () => () => 0; |
| 3630 } | 8582 } |
| 3631 '''); | 8583 '''); |
| 8584 if (isStrongMode) { |
| 8585 checkElementText( |
| 8586 library, |
| 8587 r''' |
| 8588 class C<U, V> { |
| 8589 dynamic get x {} |
| 8590 } |
| 8591 '''); |
| 8592 } else { |
| 8593 checkElementText( |
| 8594 library, |
| 8595 r''' |
| 8596 class C<U, V> { |
| 8597 dynamic get x {} |
| 8598 } |
| 8599 '''); |
| 8600 } |
| 3632 } | 8601 } |
| 3633 | 8602 |
| 3634 test_inferred_function_type_in_generic_class_in_generic_method() { | 8603 test_inferred_function_type_in_generic_class_in_generic_method() { |
| 3635 // In the code below, `() => () => 0` has an inferred return type of | 8604 // In the code below, `() => () => 0` has an inferred return type of |
| 3636 // `() => int`, with 3 (unused) type parameters from the enclosing class | 8605 // `() => int`, with 3 (unused) type parameters from the enclosing class |
| 3637 // and method. | 8606 // and method. |
| 3638 checkLibrary(''' | 8607 var library = checkLibrary(''' |
| 3639 class C<T> { | 8608 class C<T> { |
| 3640 f<U, V>() { | 8609 f<U, V>() { |
| 3641 print(() => () => 0); | 8610 print(() => () => 0); |
| 3642 } | 8611 } |
| 3643 } | 8612 } |
| 3644 '''); | 8613 '''); |
| 8614 if (isStrongMode) { |
| 8615 checkElementText( |
| 8616 library, |
| 8617 r''' |
| 8618 class C<T> { |
| 8619 dynamic f<U, V>() {} |
| 8620 } |
| 8621 '''); |
| 8622 } else { |
| 8623 checkElementText( |
| 8624 library, |
| 8625 r''' |
| 8626 class C<T> { |
| 8627 dynamic f<U, V>() {} |
| 8628 } |
| 8629 '''); |
| 8630 } |
| 3645 } | 8631 } |
| 3646 | 8632 |
| 3647 test_inferred_function_type_in_generic_class_setter() { | 8633 test_inferred_function_type_in_generic_class_setter() { |
| 3648 // In the code below, `() => () => 0` has an inferred return type of | 8634 // In the code below, `() => () => 0` has an inferred return type of |
| 3649 // `() => int`, with 2 (unused) type parameters from the enclosing class. | 8635 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 3650 checkLibrary(''' | 8636 var library = checkLibrary(''' |
| 3651 class C<U, V> { | 8637 class C<U, V> { |
| 3652 void set x(value) { | 8638 void set x(value) { |
| 3653 print(() => () => 0); | 8639 print(() => () => 0); |
| 3654 } | 8640 } |
| 3655 } | 8641 } |
| 3656 '''); | 8642 '''); |
| 8643 if (isStrongMode) { |
| 8644 checkElementText( |
| 8645 library, |
| 8646 r''' |
| 8647 class C<U, V> { |
| 8648 void set x(dynamic value) {} |
| 8649 } |
| 8650 '''); |
| 8651 } else { |
| 8652 checkElementText( |
| 8653 library, |
| 8654 r''' |
| 8655 class C<U, V> { |
| 8656 void set x(dynamic value) {} |
| 8657 } |
| 8658 '''); |
| 8659 } |
| 3657 } | 8660 } |
| 3658 | 8661 |
| 3659 test_inferred_function_type_in_generic_closure() { | 8662 test_inferred_function_type_in_generic_closure() { |
| 3660 if (!createOptions().strongMode) { | 8663 if (!createOptions().strongMode) { |
| 3661 // The test below uses generic comment syntax because proper generic | 8664 // The test below uses generic comment syntax because proper generic |
| 3662 // method syntax doesn't support generic closures. So it can only run in | 8665 // method syntax doesn't support generic closures. So it can only run in |
| 3663 // strong mode. | 8666 // strong mode. |
| 3664 // TODO(paulberry): once proper generic method syntax supports generic | 8667 // TODO(paulberry): once proper generic method syntax supports generic |
| 3665 // closures, rewrite the test below without using generic comment syntax, | 8668 // closures, rewrite the test below without using generic comment syntax, |
| 3666 // and remove this hack. See dartbug.com/25819 | 8669 // and remove this hack. See dartbug.com/25819 |
| 3667 return; | 8670 return; |
| 3668 } | 8671 } |
| 3669 // In the code below, `<U, V>() => () => 0` has an inferred return type of | 8672 // In the code below, `<U, V>() => () => 0` has an inferred return type of |
| 3670 // `() => int`, with 3 (unused) type parameters. | 8673 // `() => int`, with 3 (unused) type parameters. |
| 3671 checkLibrary(''' | 8674 var library = checkLibrary(''' |
| 3672 f<T>() { | 8675 f<T>() { |
| 3673 print(/*<U, V>*/() => () => 0); | 8676 print(/*<U, V>*/() => () => 0); |
| 3674 } | 8677 } |
| 3675 '''); | 8678 '''); |
| 8679 if (isStrongMode) { |
| 8680 checkElementText( |
| 8681 library, |
| 8682 r''' |
| 8683 dynamic f<T>() {} |
| 8684 '''); |
| 8685 } else { |
| 8686 checkElementText( |
| 8687 library, |
| 8688 r''' |
| 8689 '''); |
| 8690 } |
| 3676 } | 8691 } |
| 3677 | 8692 |
| 3678 test_inferred_generic_function_type_in_generic_closure() { | 8693 test_inferred_generic_function_type_in_generic_closure() { |
| 3679 if (!createOptions().strongMode) { | 8694 if (!createOptions().strongMode) { |
| 3680 // The test below uses generic comment syntax because proper generic | 8695 // The test below uses generic comment syntax because proper generic |
| 3681 // method syntax doesn't support generic closures. So it can only run in | 8696 // method syntax doesn't support generic closures. So it can only run in |
| 3682 // strong mode. | 8697 // strong mode. |
| 3683 // TODO(paulberry): once proper generic method syntax supports generic | 8698 // TODO(paulberry): once proper generic method syntax supports generic |
| 3684 // closures, rewrite the test below without using generic comment syntax, | 8699 // closures, rewrite the test below without using generic comment syntax, |
| 3685 // and remove this hack. See dartbug.com/25819 | 8700 // and remove this hack. See dartbug.com/25819 |
| 3686 return; | 8701 return; |
| 3687 } | 8702 } |
| 3688 // In the code below, `<U, V>() => <W, X, Y, Z>() => 0` has an inferred | 8703 // In the code below, `<U, V>() => <W, X, Y, Z>() => 0` has an inferred |
| 3689 // return type of `() => int`, with 7 (unused) type parameters. | 8704 // return type of `() => int`, with 7 (unused) type parameters. |
| 3690 checkLibrary(''' | 8705 var library = checkLibrary(''' |
| 3691 f<T>() { | 8706 f<T>() { |
| 3692 print(/*<U, V>*/() => /*<W, X, Y, Z>*/() => 0); | 8707 print(/*<U, V>*/() => /*<W, X, Y, Z>*/() => 0); |
| 3693 } | 8708 } |
| 3694 '''); | 8709 '''); |
| 8710 if (isStrongMode) { |
| 8711 checkElementText( |
| 8712 library, |
| 8713 r''' |
| 8714 dynamic f<T>() {} |
| 8715 '''); |
| 8716 } else { |
| 8717 checkElementText( |
| 8718 library, |
| 8719 r''' |
| 8720 '''); |
| 8721 } |
| 3695 } | 8722 } |
| 3696 | 8723 |
| 3697 test_inferred_type_is_typedef() { | 8724 test_inferred_type_is_typedef() { |
| 3698 checkLibrary('typedef int F(String s);' | 8725 var library = checkLibrary('typedef int F(String s);' |
| 3699 ' class C extends D { var v; }' | 8726 ' class C extends D { var v; }' |
| 3700 ' abstract class D { F get v; }'); | 8727 ' abstract class D { F get v; }'); |
| 8728 if (isStrongMode) { |
| 8729 checkElementText( |
| 8730 library, |
| 8731 r''' |
| 8732 typedef int F(String s); |
| 8733 class C extends D { |
| 8734 F v; |
| 8735 } |
| 8736 abstract class D { |
| 8737 F get v; |
| 8738 } |
| 8739 '''); |
| 8740 } else { |
| 8741 checkElementText( |
| 8742 library, |
| 8743 r''' |
| 8744 typedef int F(String s); |
| 8745 class C extends D { |
| 8746 dynamic v; |
| 8747 } |
| 8748 abstract class D { |
| 8749 F get v; |
| 8750 } |
| 8751 '''); |
| 8752 } |
| 3701 } | 8753 } |
| 3702 | 8754 |
| 3703 test_inferred_type_refers_to_bound_type_param() { | 8755 test_inferred_type_refers_to_bound_type_param() { |
| 3704 checkLibrary('class C<T> extends D<int, T> { var v; }' | 8756 var library = checkLibrary('class C<T> extends D<int, T> { var v; }' |
| 3705 ' abstract class D<U, V> { Map<V, U> get v; }'); | 8757 ' abstract class D<U, V> { Map<V, U> get v; }'); |
| 8758 if (isStrongMode) { |
| 8759 checkElementText( |
| 8760 library, |
| 8761 r''' |
| 8762 class C<T> extends D<int, T> { |
| 8763 Map<T, int> v; |
| 8764 } |
| 8765 abstract class D<U, V> { |
| 8766 Map<V, U> get v; |
| 8767 } |
| 8768 '''); |
| 8769 } else { |
| 8770 checkElementText( |
| 8771 library, |
| 8772 r''' |
| 8773 class C<T> extends D<int, T> { |
| 8774 dynamic v; |
| 8775 } |
| 8776 abstract class D<U, V> { |
| 8777 Map<V, U> get v; |
| 8778 } |
| 8779 '''); |
| 8780 } |
| 3706 } | 8781 } |
| 3707 | 8782 |
| 3708 void test_inferred_type_refers_to_function_typed_param_of_typedef() { | 8783 void test_inferred_type_refers_to_function_typed_param_of_typedef() { |
| 3709 checkLibrary(''' | 8784 var library = checkLibrary(''' |
| 3710 typedef void F(int g(String s)); | 8785 typedef void F(int g(String s)); |
| 3711 h(F f) => null; | 8786 h(F f) => null; |
| 3712 var v = h(/*info:INFERRED_TYPE_CLOSURE*/(y) {}); | 8787 var v = h(/*info:INFERRED_TYPE_CLOSURE*/(y) {}); |
| 3713 '''); | 8788 '''); |
| 8789 if (isStrongMode) { |
| 8790 checkElementText( |
| 8791 library, |
| 8792 r''' |
| 8793 typedef void F((String) → int g); |
| 8794 dynamic v; |
| 8795 dynamic h(F f) {} |
| 8796 '''); |
| 8797 } else { |
| 8798 checkElementText( |
| 8799 library, |
| 8800 r''' |
| 8801 typedef void F((String) → int g); |
| 8802 dynamic v; |
| 8803 dynamic h(F f) {} |
| 8804 '''); |
| 8805 } |
| 3714 } | 8806 } |
| 3715 | 8807 |
| 3716 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { | 8808 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { |
| 3717 checkLibrary('class C<T, U> extends D<U, int> { void f(int x, g) {} }' | 8809 var library = |
| 3718 ' abstract class D<V, W> { void f(int x, W g(V s)); }'); | 8810 checkLibrary('class C<T, U> extends D<U, int> { void f(int x, g) {} }' |
| 8811 ' abstract class D<V, W> { void f(int x, W g(V s)); }'); |
| 8812 if (isStrongMode) { |
| 8813 checkElementText( |
| 8814 library, |
| 8815 r''' |
| 8816 class C<T, U> extends D<U, int> { |
| 8817 void f(int x, (U) → int g) {} |
| 8818 } |
| 8819 abstract class D<V, W> { |
| 8820 void f(int x, (V) → W g); |
| 8821 } |
| 8822 '''); |
| 8823 } else { |
| 8824 checkElementText( |
| 8825 library, |
| 8826 r''' |
| 8827 class C<T, U> extends D<U, int> { |
| 8828 void f(int x, dynamic g) {} |
| 8829 } |
| 8830 abstract class D<V, W> { |
| 8831 void f(int x, (V) → W g); |
| 8832 } |
| 8833 '''); |
| 8834 } |
| 3719 } | 8835 } |
| 3720 | 8836 |
| 3721 test_inferred_type_refers_to_function_typed_parameter_type_other_lib() { | 8837 test_inferred_type_refers_to_function_typed_parameter_type_other_lib() { |
| 3722 addLibrarySource( | 8838 addLibrarySource( |
| 3723 '/a.dart', 'import "b.dart"; abstract class D extends E {}'); | 8839 '/a.dart', 'import "b.dart"; abstract class D extends E {}'); |
| 3724 addLibrarySource( | 8840 addLibrarySource( |
| 3725 '/b.dart', 'abstract class E { void f(int x, int g(String s)); }'); | 8841 '/b.dart', 'abstract class E { void f(int x, int g(String s)); }'); |
| 3726 checkLibrary('import "a.dart"; class C extends D { void f(int x, g) {} }'); | 8842 var library = checkLibrary( |
| 8843 'import "a.dart"; class C extends D { void f(int x, g) {} }'); |
| 8844 if (isStrongMode) { |
| 8845 checkElementText( |
| 8846 library, |
| 8847 r''' |
| 8848 import 'a.dart'; |
| 8849 class C extends D { |
| 8850 void f(int x, (String) → int g) {} |
| 8851 } |
| 8852 '''); |
| 8853 } else { |
| 8854 checkElementText( |
| 8855 library, |
| 8856 r''' |
| 8857 import 'a.dart'; |
| 8858 class C extends D { |
| 8859 void f(int x, dynamic g) {} |
| 8860 } |
| 8861 '''); |
| 8862 } |
| 3727 } | 8863 } |
| 3728 | 8864 |
| 3729 test_inferred_type_refers_to_method_function_typed_parameter_type() { | 8865 test_inferred_type_refers_to_method_function_typed_parameter_type() { |
| 3730 checkLibrary('class C extends D { void f(int x, g) {} }' | 8866 var library = checkLibrary('class C extends D { void f(int x, g) {} }' |
| 3731 ' abstract class D { void f(int x, int g(String s)); }'); | 8867 ' abstract class D { void f(int x, int g(String s)); }'); |
| 8868 if (isStrongMode) { |
| 8869 checkElementText( |
| 8870 library, |
| 8871 r''' |
| 8872 class C extends D { |
| 8873 void f(int x, (String) → int g) {} |
| 8874 } |
| 8875 abstract class D { |
| 8876 void f(int x, (String) → int g); |
| 8877 } |
| 8878 '''); |
| 8879 } else { |
| 8880 checkElementText( |
| 8881 library, |
| 8882 r''' |
| 8883 class C extends D { |
| 8884 void f(int x, dynamic g) {} |
| 8885 } |
| 8886 abstract class D { |
| 8887 void f(int x, (String) → int g); |
| 8888 } |
| 8889 '''); |
| 8890 } |
| 3732 } | 8891 } |
| 3733 | 8892 |
| 3734 test_inferred_type_refers_to_nested_function_typed_param() { | 8893 test_inferred_type_refers_to_nested_function_typed_param() { |
| 3735 checkLibrary(''' | 8894 var library = checkLibrary(''' |
| 3736 f(void g(int x, void h())) => null; | 8895 f(void g(int x, void h())) => null; |
| 3737 var v = f((x, y) {}); | 8896 var v = f((x, y) {}); |
| 3738 '''); | 8897 '''); |
| 8898 if (isStrongMode) { |
| 8899 checkElementText( |
| 8900 library, |
| 8901 r''' |
| 8902 dynamic v; |
| 8903 dynamic f((int, () → void) → void g) {} |
| 8904 '''); |
| 8905 } else { |
| 8906 checkElementText( |
| 8907 library, |
| 8908 r''' |
| 8909 dynamic v; |
| 8910 dynamic f((int, () → void) → void g) {} |
| 8911 '''); |
| 8912 } |
| 3739 } | 8913 } |
| 3740 | 8914 |
| 3741 test_inferred_type_refers_to_nested_function_typed_param_named() { | 8915 test_inferred_type_refers_to_nested_function_typed_param_named() { |
| 3742 checkLibrary(''' | 8916 var library = checkLibrary(''' |
| 3743 f({void g(int x, void h())}) => null; | 8917 f({void g(int x, void h())}) => null; |
| 3744 var v = f(g: (x, y) {}); | 8918 var v = f(g: (x, y) {}); |
| 3745 '''); | 8919 '''); |
| 8920 if (isStrongMode) { |
| 8921 checkElementText( |
| 8922 library, |
| 8923 r''' |
| 8924 dynamic v; |
| 8925 dynamic f({(int, () → void) → void g}) {} |
| 8926 '''); |
| 8927 } else { |
| 8928 checkElementText( |
| 8929 library, |
| 8930 r''' |
| 8931 dynamic v; |
| 8932 dynamic f({(int, () → void) → void g}) {} |
| 8933 '''); |
| 8934 } |
| 3746 } | 8935 } |
| 3747 | 8936 |
| 3748 test_inferred_type_refers_to_setter_function_typed_parameter_type() { | 8937 test_inferred_type_refers_to_setter_function_typed_parameter_type() { |
| 3749 checkLibrary('class C extends D { void set f(g) {} }' | 8938 var library = checkLibrary('class C extends D { void set f(g) {} }' |
| 3750 ' abstract class D { void set f(int g(String s)); }'); | 8939 ' abstract class D { void set f(int g(String s)); }'); |
| 8940 if (isStrongMode) { |
| 8941 checkElementText( |
| 8942 library, |
| 8943 r''' |
| 8944 class C extends D { |
| 8945 void set f((String) → int g) {} |
| 8946 } |
| 8947 abstract class D { |
| 8948 void set f((String) → int g); |
| 8949 } |
| 8950 '''); |
| 8951 } else { |
| 8952 checkElementText( |
| 8953 library, |
| 8954 r''' |
| 8955 class C extends D { |
| 8956 void set f(dynamic g) {} |
| 8957 } |
| 8958 abstract class D { |
| 8959 void set f((String) → int g); |
| 8960 } |
| 8961 '''); |
| 8962 } |
| 3751 } | 8963 } |
| 3752 | 8964 |
| 3753 void test_inferredType_definedInSdkLibraryPart() { | 8965 void test_inferredType_definedInSdkLibraryPart() { |
| 3754 addSource( | 8966 addSource( |
| 3755 '/a.dart', | 8967 '/a.dart', |
| 3756 r''' | 8968 r''' |
| 3757 import 'dart:async'; | 8969 import 'dart:async'; |
| 3758 class A { | 8970 class A { |
| 3759 m(Stream p) {} | 8971 m(Stream p) {} |
| 3760 } | 8972 } |
| 3761 '''); | 8973 '''); |
| 3762 LibraryElement library = checkLibrary(r''' | 8974 LibraryElement library = checkLibrary(r''' |
| 3763 import 'a.dart'; | 8975 import 'a.dart'; |
| 3764 class B extends A { | 8976 class B extends A { |
| 3765 m(p) {} | 8977 m(p) {} |
| 3766 } | 8978 } |
| 3767 '''); | 8979 '''); |
| 8980 if (isStrongMode) { |
| 8981 checkElementText( |
| 8982 library, |
| 8983 r''' |
| 8984 import 'a.dart'; |
| 8985 class B extends A { |
| 8986 dynamic m(Stream<dynamic> p) {} |
| 8987 } |
| 8988 '''); |
| 8989 } else { |
| 8990 checkElementText( |
| 8991 library, |
| 8992 r''' |
| 8993 import 'a.dart'; |
| 8994 class B extends A { |
| 8995 dynamic m(dynamic p) {} |
| 8996 } |
| 8997 '''); |
| 8998 } |
| 3768 ClassElement b = library.definingCompilationUnit.types[0]; | 8999 ClassElement b = library.definingCompilationUnit.types[0]; |
| 3769 ParameterElement p = b.methods[0].parameters[0]; | 9000 ParameterElement p = b.methods[0].parameters[0]; |
| 3770 // This test should verify that we correctly record inferred types, | 9001 // This test should verify that we correctly record inferred types, |
| 3771 // when the type is defined in a part of an SDK library. So, test that | 9002 // when the type is defined in a part of an SDK library. So, test that |
| 3772 // the type is actually in a part. | 9003 // the type is actually in a part. |
| 3773 Element streamElement = p.type.element; | 9004 Element streamElement = p.type.element; |
| 3774 if (streamElement is ClassElement) { | 9005 if (streamElement is ClassElement) { |
| 3775 expect(streamElement.source, isNot(streamElement.library.source)); | 9006 expect(streamElement.source, isNot(streamElement.library.source)); |
| 3776 } | 9007 } |
| 3777 } | 9008 } |
| 3778 | 9009 |
| 3779 void test_inferredType_usesSyntheticFunctionType_functionTypedParam() { | 9010 void test_inferredType_usesSyntheticFunctionType_functionTypedParam() { |
| 3780 checkLibrary(''' | 9011 var library = checkLibrary(''' |
| 3781 int f(int x(String y)) => null; | 9012 int f(int x(String y)) => null; |
| 3782 String g(int x(String y)) => null; | 9013 String g(int x(String y)) => null; |
| 3783 var v = [f, g]; | 9014 var v = [f, g]; |
| 3784 '''); | 9015 '''); |
| 9016 if (isStrongMode) { |
| 9017 checkElementText( |
| 9018 library, |
| 9019 r''' |
| 9020 List<((String) → int) → Object> v; |
| 9021 int f((String) → int x) {} |
| 9022 String g((String) → int x) {} |
| 9023 '''); |
| 9024 } else { |
| 9025 checkElementText( |
| 9026 library, |
| 9027 r''' |
| 9028 dynamic v; |
| 9029 int f((String) → int x) {} |
| 9030 String g((String) → int x) {} |
| 9031 '''); |
| 9032 } |
| 3785 } | 9033 } |
| 3786 | 9034 |
| 3787 test_inheritance_errors() { | 9035 test_inheritance_errors() { |
| 3788 checkLibrary(''' | 9036 var library = checkLibrary(''' |
| 3789 abstract class A { | 9037 abstract class A { |
| 3790 int m(); | 9038 int m(); |
| 3791 } | 9039 } |
| 3792 | 9040 |
| 3793 abstract class B { | 9041 abstract class B { |
| 3794 String m(); | 9042 String m(); |
| 3795 } | 9043 } |
| 3796 | 9044 |
| 3797 abstract class C implements A, B {} | 9045 abstract class C implements A, B {} |
| 3798 | 9046 |
| 3799 abstract class D extends C { | 9047 abstract class D extends C { |
| 3800 var f; | 9048 var f; |
| 3801 } | 9049 } |
| 3802 '''); | 9050 '''); |
| 9051 if (isStrongMode) { |
| 9052 checkElementText( |
| 9053 library, |
| 9054 r''' |
| 9055 abstract class A { |
| 9056 int m(); |
| 9057 } |
| 9058 abstract class B { |
| 9059 String m(); |
| 9060 } |
| 9061 abstract class C implements A, B { |
| 9062 } |
| 9063 abstract class D extends C { |
| 9064 dynamic f; |
| 9065 } |
| 9066 '''); |
| 9067 } else { |
| 9068 checkElementText( |
| 9069 library, |
| 9070 r''' |
| 9071 abstract class A { |
| 9072 int m(); |
| 9073 } |
| 9074 abstract class B { |
| 9075 String m(); |
| 9076 } |
| 9077 abstract class C implements A, B { |
| 9078 } |
| 9079 abstract class D extends C { |
| 9080 dynamic f; |
| 9081 } |
| 9082 '''); |
| 9083 } |
| 3803 } | 9084 } |
| 3804 | 9085 |
| 3805 test_initializer_executable_with_return_type_from_closure() { | 9086 test_initializer_executable_with_return_type_from_closure() { |
| 3806 checkLibrary('var v = () => 0;'); | 9087 var library = checkLibrary('var v = () => 0;'); |
| 9088 if (isStrongMode) { |
| 9089 checkElementText( |
| 9090 library, |
| 9091 r''' |
| 9092 () → int v; |
| 9093 '''); |
| 9094 } else { |
| 9095 checkElementText( |
| 9096 library, |
| 9097 r''' |
| 9098 dynamic v; |
| 9099 '''); |
| 9100 } |
| 3807 } | 9101 } |
| 3808 | 9102 |
| 3809 test_initializer_executable_with_return_type_from_closure_await_dynamic() { | 9103 test_initializer_executable_with_return_type_from_closure_await_dynamic() { |
| 3810 checkLibrary('var v = (f) async => await f;'); | 9104 var library = checkLibrary('var v = (f) async => await f;'); |
| 9105 if (isStrongMode) { |
| 9106 checkElementText( |
| 9107 library, |
| 9108 r''' |
| 9109 (dynamic) → Future<dynamic> v; |
| 9110 '''); |
| 9111 } else { |
| 9112 checkElementText( |
| 9113 library, |
| 9114 r''' |
| 9115 dynamic v; |
| 9116 '''); |
| 9117 } |
| 3811 } | 9118 } |
| 3812 | 9119 |
| 3813 test_initializer_executable_with_return_type_from_closure_await_future3_int()
{ | 9120 test_initializer_executable_with_return_type_from_closure_await_future3_int()
{ |
| 3814 checkLibrary(r''' | 9121 var library = checkLibrary(r''' |
| 3815 import 'dart:async'; | 9122 import 'dart:async'; |
| 3816 var v = (Future<Future<Future<int>>> f) async => await f; | 9123 var v = (Future<Future<Future<int>>> f) async => await f; |
| 3817 '''); | 9124 '''); |
| 9125 if (isStrongMode) { |
| 9126 checkElementText( |
| 9127 library, |
| 9128 r''' |
| 9129 import 'dart:async'; |
| 9130 (Future<Future<Future<int>>>) → Future<int> v; |
| 9131 '''); |
| 9132 } else { |
| 9133 checkElementText( |
| 9134 library, |
| 9135 r''' |
| 9136 import 'dart:async'; |
| 9137 dynamic v; |
| 9138 '''); |
| 9139 } |
| 3818 } | 9140 } |
| 3819 | 9141 |
| 3820 test_initializer_executable_with_return_type_from_closure_await_future_int() { | 9142 test_initializer_executable_with_return_type_from_closure_await_future_int() { |
| 3821 checkLibrary(r''' | 9143 var library = checkLibrary(r''' |
| 3822 import 'dart:async'; | 9144 import 'dart:async'; |
| 3823 var v = (Future<int> f) async => await f; | 9145 var v = (Future<int> f) async => await f; |
| 3824 '''); | 9146 '''); |
| 9147 if (isStrongMode) { |
| 9148 checkElementText( |
| 9149 library, |
| 9150 r''' |
| 9151 import 'dart:async'; |
| 9152 (Future<int>) → Future<int> v; |
| 9153 '''); |
| 9154 } else { |
| 9155 checkElementText( |
| 9156 library, |
| 9157 r''' |
| 9158 import 'dart:async'; |
| 9159 dynamic v; |
| 9160 '''); |
| 9161 } |
| 3825 } | 9162 } |
| 3826 | 9163 |
| 3827 test_initializer_executable_with_return_type_from_closure_await_future_noArg()
{ | 9164 test_initializer_executable_with_return_type_from_closure_await_future_noArg()
{ |
| 3828 checkLibrary(r''' | 9165 var library = checkLibrary(r''' |
| 3829 import 'dart:async'; | 9166 import 'dart:async'; |
| 3830 var v = (Future f) async => await f; | 9167 var v = (Future f) async => await f; |
| 3831 '''); | 9168 '''); |
| 9169 if (isStrongMode) { |
| 9170 checkElementText( |
| 9171 library, |
| 9172 r''' |
| 9173 import 'dart:async'; |
| 9174 (Future<dynamic>) → Future<dynamic> v; |
| 9175 '''); |
| 9176 } else { |
| 9177 checkElementText( |
| 9178 library, |
| 9179 r''' |
| 9180 import 'dart:async'; |
| 9181 dynamic v; |
| 9182 '''); |
| 9183 } |
| 3832 } | 9184 } |
| 3833 | 9185 |
| 3834 test_initializer_executable_with_return_type_from_closure_field() { | 9186 test_initializer_executable_with_return_type_from_closure_field() { |
| 3835 checkLibrary(''' | 9187 var library = checkLibrary(''' |
| 3836 class C { | 9188 class C { |
| 3837 var v = () => 0; | 9189 var v = () => 0; |
| 3838 } | 9190 } |
| 3839 '''); | 9191 '''); |
| 9192 if (isStrongMode) { |
| 9193 checkElementText( |
| 9194 library, |
| 9195 r''' |
| 9196 class C { |
| 9197 () → int v; |
| 9198 } |
| 9199 '''); |
| 9200 } else { |
| 9201 checkElementText( |
| 9202 library, |
| 9203 r''' |
| 9204 class C { |
| 9205 dynamic v; |
| 9206 } |
| 9207 '''); |
| 9208 } |
| 3840 } | 9209 } |
| 3841 | 9210 |
| 3842 test_initializer_executable_with_return_type_from_closure_local() { | 9211 test_initializer_executable_with_return_type_from_closure_local() { |
| 3843 checkLibrary(''' | 9212 var library = checkLibrary(''' |
| 3844 void f() { | 9213 void f() { |
| 3845 int u = 0; | 9214 int u = 0; |
| 3846 var v = () => 0; | 9215 var v = () => 0; |
| 3847 } | 9216 } |
| 3848 '''); | 9217 '''); |
| 9218 if (isStrongMode) { |
| 9219 checkElementText( |
| 9220 library, |
| 9221 r''' |
| 9222 void f() {} |
| 9223 '''); |
| 9224 } else { |
| 9225 checkElementText( |
| 9226 library, |
| 9227 r''' |
| 9228 void f() {} |
| 9229 '''); |
| 9230 } |
| 3849 } | 9231 } |
| 3850 | 9232 |
| 3851 test_instantiateToBounds_boundRefersToEarlierTypeArgument() { | 9233 test_instantiateToBounds_boundRefersToEarlierTypeArgument() { |
| 3852 checkLibrary(''' | 9234 var library = checkLibrary(''' |
| 3853 class C<S extends num, T extends C<S, T>> {} | 9235 class C<S extends num, T extends C<S, T>> {} |
| 3854 C c; | 9236 C c; |
| 3855 '''); | 9237 '''); |
| 9238 if (isStrongMode) { |
| 9239 checkElementText( |
| 9240 library, |
| 9241 r''' |
| 9242 class C<S extends num, T extends C<S, T>> { |
| 9243 } |
| 9244 C<num, C<num, dynamic>> c; |
| 9245 '''); |
| 9246 } else { |
| 9247 checkElementText( |
| 9248 library, |
| 9249 r''' |
| 9250 class C<S extends num, T extends C<S, T>> { |
| 9251 } |
| 9252 C<dynamic, dynamic> c; |
| 9253 '''); |
| 9254 } |
| 3856 } | 9255 } |
| 3857 | 9256 |
| 3858 test_instantiateToBounds_boundRefersToItself() { | 9257 test_instantiateToBounds_boundRefersToItself() { |
| 3859 checkLibrary(''' | 9258 var library = checkLibrary(''' |
| 3860 class C<T extends C<T>> {} | 9259 class C<T extends C<T>> {} |
| 3861 C c; | 9260 C c; |
| 3862 var c2 = new C(); | 9261 var c2 = new C(); |
| 3863 class B { | 9262 class B { |
| 3864 var c3 = new C(); | 9263 var c3 = new C(); |
| 3865 } | 9264 } |
| 3866 '''); | 9265 '''); |
| 9266 if (isStrongMode) { |
| 9267 checkElementText( |
| 9268 library, |
| 9269 r''' |
| 9270 class C<T extends C<T>> { |
| 9271 } |
| 9272 class B { |
| 9273 C<C<dynamic>> c3; |
| 9274 } |
| 9275 C<C<dynamic>> c; |
| 9276 C<C<dynamic>> c2; |
| 9277 '''); |
| 9278 } else { |
| 9279 checkElementText( |
| 9280 library, |
| 9281 r''' |
| 9282 class C<T extends C<T>> { |
| 9283 } |
| 9284 class B { |
| 9285 dynamic c3; |
| 9286 } |
| 9287 C<dynamic> c; |
| 9288 dynamic c2; |
| 9289 '''); |
| 9290 } |
| 3867 } | 9291 } |
| 3868 | 9292 |
| 3869 test_instantiateToBounds_boundRefersToLaterTypeArgument() { | 9293 test_instantiateToBounds_boundRefersToLaterTypeArgument() { |
| 3870 checkLibrary(''' | 9294 var library = checkLibrary(''' |
| 3871 class C<T extends C<T, U>, U extends num> {} | 9295 class C<T extends C<T, U>, U extends num> {} |
| 3872 C c; | 9296 C c; |
| 3873 '''); | 9297 '''); |
| 9298 if (isStrongMode) { |
| 9299 checkElementText( |
| 9300 library, |
| 9301 r''' |
| 9302 class C<T extends C<T, U>, U extends num> { |
| 9303 } |
| 9304 C<C<dynamic, num>, num> c; |
| 9305 '''); |
| 9306 } else { |
| 9307 checkElementText( |
| 9308 library, |
| 9309 r''' |
| 9310 class C<T extends C<T, U>, U extends num> { |
| 9311 } |
| 9312 C<dynamic, dynamic> c; |
| 9313 '''); |
| 9314 } |
| 3874 } | 9315 } |
| 3875 | 9316 |
| 3876 test_instantiateToBounds_functionTypeAlias_simple() { | 9317 test_instantiateToBounds_functionTypeAlias_simple() { |
| 3877 checkLibrary(''' | 9318 var library = checkLibrary(''' |
| 3878 typedef F<T extends num>(T p); | 9319 typedef F<T extends num>(T p); |
| 3879 F f; | 9320 F f; |
| 3880 '''); | 9321 '''); |
| 9322 if (isStrongMode) { |
| 9323 checkElementText( |
| 9324 library, |
| 9325 r''' |
| 9326 typedef dynamic F<T extends num>(T p); |
| 9327 F f; |
| 9328 '''); |
| 9329 } else { |
| 9330 checkElementText( |
| 9331 library, |
| 9332 r''' |
| 9333 typedef dynamic F<T extends num>(T p); |
| 9334 F f; |
| 9335 '''); |
| 9336 } |
| 3881 } | 9337 } |
| 3882 | 9338 |
| 3883 test_instantiateToBounds_simple() { | 9339 test_instantiateToBounds_simple() { |
| 3884 checkLibrary(''' | 9340 var library = checkLibrary(''' |
| 3885 class C<T extends num> {} | 9341 class C<T extends num> {} |
| 3886 C c; | 9342 C c; |
| 3887 '''); | 9343 '''); |
| 9344 if (isStrongMode) { |
| 9345 checkElementText( |
| 9346 library, |
| 9347 r''' |
| 9348 class C<T extends num> { |
| 9349 } |
| 9350 C<num> c; |
| 9351 '''); |
| 9352 } else { |
| 9353 checkElementText( |
| 9354 library, |
| 9355 r''' |
| 9356 class C<T extends num> { |
| 9357 } |
| 9358 C<dynamic> c; |
| 9359 '''); |
| 9360 } |
| 3888 } | 9361 } |
| 3889 | 9362 |
| 3890 test_invalid_annotation_prefixed_constructor() { | 9363 test_invalid_annotation_prefixed_constructor() { |
| 3891 addLibrarySource( | 9364 addLibrarySource( |
| 3892 '/a.dart', | 9365 '/a.dart', |
| 3893 r''' | 9366 r''' |
| 3894 class C { | 9367 class C { |
| 3895 const C.named(); | 9368 const C.named(); |
| 3896 } | 9369 } |
| 3897 '''); | 9370 '''); |
| 3898 checkLibrary(''' | 9371 var library = checkLibrary(''' |
| 3899 import "a.dart" as a; | 9372 import "a.dart" as a; |
| 3900 @a.C.named | 9373 @a.C.named |
| 3901 class D {} | 9374 class D {} |
| 3902 '''); | 9375 '''); |
| 9376 if (isStrongMode) { |
| 9377 checkElementText( |
| 9378 library, |
| 9379 r''' |
| 9380 import 'a.dart' as a; |
| 9381 @a.C.named |
| 9382 class D { |
| 9383 } |
| 9384 '''); |
| 9385 } else { |
| 9386 checkElementText( |
| 9387 library, |
| 9388 r''' |
| 9389 import 'a.dart' as a; |
| 9390 @a.C.named |
| 9391 class D { |
| 9392 } |
| 9393 '''); |
| 9394 } |
| 3903 } | 9395 } |
| 3904 | 9396 |
| 3905 test_invalid_annotation_unprefixed_constructor() { | 9397 test_invalid_annotation_unprefixed_constructor() { |
| 3906 addLibrarySource( | 9398 addLibrarySource( |
| 3907 '/a.dart', | 9399 '/a.dart', |
| 3908 r''' | 9400 r''' |
| 3909 class C { | 9401 class C { |
| 3910 const C.named(); | 9402 const C.named(); |
| 3911 } | 9403 } |
| 3912 '''); | 9404 '''); |
| 3913 checkLibrary(''' | 9405 var library = checkLibrary(''' |
| 3914 import "a.dart"; | 9406 import "a.dart"; |
| 3915 @C.named | 9407 @C.named |
| 3916 class D {} | 9408 class D {} |
| 3917 '''); | 9409 '''); |
| 9410 if (isStrongMode) { |
| 9411 checkElementText( |
| 9412 library, |
| 9413 r''' |
| 9414 import 'a.dart'; |
| 9415 @C.named |
| 9416 class D { |
| 9417 } |
| 9418 '''); |
| 9419 } else { |
| 9420 checkElementText( |
| 9421 library, |
| 9422 r''' |
| 9423 import 'a.dart'; |
| 9424 @C.named |
| 9425 class D { |
| 9426 } |
| 9427 '''); |
| 9428 } |
| 3918 } | 9429 } |
| 3919 | 9430 |
| 3920 test_invalid_importPrefix_asTypeArgument() { | 9431 test_invalid_importPrefix_asTypeArgument() { |
| 3921 checkLibrary(''' | 9432 var library = checkLibrary(''' |
| 3922 import 'dart:async' as ppp; | 9433 import 'dart:async' as ppp; |
| 3923 class C { | 9434 class C { |
| 3924 List<ppp> v; | 9435 List<ppp> v; |
| 3925 } | 9436 } |
| 3926 '''); | 9437 '''); |
| 9438 if (isStrongMode) { |
| 9439 checkElementText( |
| 9440 library, |
| 9441 r''' |
| 9442 import 'dart:async' as ppp; |
| 9443 class C { |
| 9444 List<dynamic> v; |
| 9445 } |
| 9446 '''); |
| 9447 } else { |
| 9448 checkElementText( |
| 9449 library, |
| 9450 r''' |
| 9451 import 'dart:async' as ppp; |
| 9452 class C { |
| 9453 List<dynamic> v; |
| 9454 } |
| 9455 '''); |
| 9456 } |
| 3927 } | 9457 } |
| 3928 | 9458 |
| 3929 test_invalid_nameConflict_imported() { | 9459 test_invalid_nameConflict_imported() { |
| 3930 namesThatCannotBeResolved.add('V'); | 9460 namesThatCannotBeResolved.add('V'); |
| 3931 addLibrarySource('/a.dart', 'V() {}'); | 9461 addLibrarySource('/a.dart', 'V() {}'); |
| 3932 addLibrarySource('/b.dart', 'V() {}'); | 9462 addLibrarySource('/b.dart', 'V() {}'); |
| 3933 checkLibrary(''' | 9463 var library = checkLibrary(''' |
| 3934 import 'a.dart'; | 9464 import 'a.dart'; |
| 3935 import 'b.dart'; | 9465 import 'b.dart'; |
| 3936 foo([p = V]) {} | 9466 foo([p = V]) {} |
| 3937 '''); | 9467 '''); |
| 9468 if (isStrongMode) { |
| 9469 checkElementText( |
| 9470 library, |
| 9471 r''' |
| 9472 import 'a.dart'; |
| 9473 import 'b.dart'; |
| 9474 dynamic foo([dynamic p = V]) {} |
| 9475 '''); |
| 9476 } else { |
| 9477 checkElementText( |
| 9478 library, |
| 9479 r''' |
| 9480 import 'a.dart'; |
| 9481 import 'b.dart'; |
| 9482 dynamic foo([dynamic p = V]) {} |
| 9483 '''); |
| 9484 } |
| 3938 } | 9485 } |
| 3939 | 9486 |
| 3940 test_invalid_nameConflict_imported_exported() { | 9487 test_invalid_nameConflict_imported_exported() { |
| 3941 namesThatCannotBeResolved.add('V'); | 9488 namesThatCannotBeResolved.add('V'); |
| 3942 addLibrarySource('/a.dart', 'V() {}'); | 9489 addLibrarySource('/a.dart', 'V() {}'); |
| 3943 addLibrarySource('/b.dart', 'V() {}'); | 9490 addLibrarySource('/b.dart', 'V() {}'); |
| 3944 addLibrarySource( | 9491 addLibrarySource( |
| 3945 '/c.dart', | 9492 '/c.dart', |
| 3946 r''' | 9493 r''' |
| 3947 export 'a.dart'; | 9494 export 'a.dart'; |
| 3948 export 'b.dart'; | 9495 export 'b.dart'; |
| 3949 '''); | 9496 '''); |
| 3950 checkLibrary(''' | 9497 var library = checkLibrary(''' |
| 3951 import 'c.dart'; | 9498 import 'c.dart'; |
| 3952 foo([p = V]) {} | 9499 foo([p = V]) {} |
| 3953 '''); | 9500 '''); |
| 9501 if (isStrongMode) { |
| 9502 checkElementText( |
| 9503 library, |
| 9504 r''' |
| 9505 import 'c.dart'; |
| 9506 dynamic foo([dynamic p = V]) {} |
| 9507 '''); |
| 9508 } else { |
| 9509 checkElementText( |
| 9510 library, |
| 9511 r''' |
| 9512 import 'c.dart'; |
| 9513 dynamic foo([dynamic p = V]) {} |
| 9514 '''); |
| 9515 } |
| 3954 } | 9516 } |
| 3955 | 9517 |
| 3956 test_invalid_nameConflict_local() { | 9518 test_invalid_nameConflict_local() { |
| 3957 namesThatCannotBeResolved.add('V'); | 9519 namesThatCannotBeResolved.add('V'); |
| 3958 checkLibrary(''' | 9520 var library = checkLibrary(''' |
| 3959 foo([p = V]) {} | 9521 foo([p = V]) {} |
| 3960 V() {} | 9522 V() {} |
| 3961 var V; | 9523 var V; |
| 3962 '''); | 9524 '''); |
| 9525 if (isStrongMode) { |
| 9526 checkElementText( |
| 9527 library, |
| 9528 r''' |
| 9529 dynamic V; |
| 9530 dynamic foo([dynamic p = V]) {} |
| 9531 dynamic V() {} |
| 9532 '''); |
| 9533 } else { |
| 9534 checkElementText( |
| 9535 library, |
| 9536 r''' |
| 9537 dynamic V; |
| 9538 dynamic foo([dynamic p = V]) {} |
| 9539 dynamic V() {} |
| 9540 '''); |
| 9541 } |
| 3963 } | 9542 } |
| 3964 | 9543 |
| 3965 test_invalid_setterParameter_fieldFormalParameter() { | 9544 test_invalid_setterParameter_fieldFormalParameter() { |
| 3966 checkLibrary(''' | 9545 var library = checkLibrary(''' |
| 3967 class C { | 9546 class C { |
| 3968 int foo; | 9547 int foo; |
| 3969 void set bar(this.foo) {} | 9548 void set bar(this.foo) {} |
| 3970 } | 9549 } |
| 3971 '''); | 9550 '''); |
| 9551 if (isStrongMode) { |
| 9552 checkElementText( |
| 9553 library, |
| 9554 r''' |
| 9555 class C { |
| 9556 int foo; |
| 9557 void set bar(dynamic this.foo) {} |
| 9558 } |
| 9559 '''); |
| 9560 } else { |
| 9561 checkElementText( |
| 9562 library, |
| 9563 r''' |
| 9564 class C { |
| 9565 int foo; |
| 9566 void set bar(dynamic this.foo) {} |
| 9567 } |
| 9568 '''); |
| 9569 } |
| 3972 } | 9570 } |
| 3973 | 9571 |
| 3974 test_invalid_setterParameter_fieldFormalParameter_self() { | 9572 test_invalid_setterParameter_fieldFormalParameter_self() { |
| 3975 checkLibrary(''' | 9573 var library = checkLibrary(''' |
| 3976 class C { | 9574 class C { |
| 3977 set x(this.x) {} | 9575 set x(this.x) {} |
| 3978 } | 9576 } |
| 3979 '''); | 9577 '''); |
| 9578 if (isStrongMode) { |
| 9579 checkElementText( |
| 9580 library, |
| 9581 r''' |
| 9582 class C { |
| 9583 void set x(dynamic this.x) {} |
| 9584 } |
| 9585 '''); |
| 9586 } else { |
| 9587 checkElementText( |
| 9588 library, |
| 9589 r''' |
| 9590 class C { |
| 9591 dynamic set x(dynamic this.x) {} |
| 9592 } |
| 9593 '''); |
| 9594 } |
| 3980 } | 9595 } |
| 3981 | 9596 |
| 3982 test_invalidUris() { | 9597 test_invalidUris() { |
| 3983 allowMissingFiles = true; | 9598 allowMissingFiles = true; |
| 3984 checkLibrary(r''' | 9599 var library = checkLibrary(r''' |
| 3985 import '[invalid uri]'; | 9600 import '[invalid uri]'; |
| 3986 import '[invalid uri]:foo.dart'; | 9601 import '[invalid uri]:foo.dart'; |
| 3987 import 'a1.dart'; | 9602 import 'a1.dart'; |
| 3988 import '[invalid uri]'; | 9603 import '[invalid uri]'; |
| 3989 import '[invalid uri]:foo.dart'; | 9604 import '[invalid uri]:foo.dart'; |
| 3990 | 9605 |
| 3991 export '[invalid uri]'; | 9606 export '[invalid uri]'; |
| 3992 export '[invalid uri]:foo.dart'; | 9607 export '[invalid uri]:foo.dart'; |
| 3993 export 'a2.dart'; | 9608 export 'a2.dart'; |
| 3994 export '[invalid uri]'; | 9609 export '[invalid uri]'; |
| 3995 export '[invalid uri]:foo.dart'; | 9610 export '[invalid uri]:foo.dart'; |
| 3996 | 9611 |
| 3997 part '[invalid uri]'; | 9612 part '[invalid uri]'; |
| 3998 part 'a3.dart'; | 9613 part 'a3.dart'; |
| 3999 part '[invalid uri]'; | 9614 part '[invalid uri]'; |
| 4000 '''); | 9615 '''); |
| 9616 if (isStrongMode) { |
| 9617 checkElementText( |
| 9618 library, |
| 9619 r''' |
| 9620 import 'a1.dart'; |
| 9621 export 'a2.dart'; |
| 9622 part 'a3.dart'; |
| 9623 -------------------- |
| 9624 unit: a3.dart |
| 9625 |
| 9626 '''); |
| 9627 } else { |
| 9628 checkElementText( |
| 9629 library, |
| 9630 r''' |
| 9631 import 'a1.dart'; |
| 9632 export 'a2.dart'; |
| 9633 part 'a3.dart'; |
| 9634 -------------------- |
| 9635 unit: a3.dart |
| 9636 |
| 9637 '''); |
| 9638 } |
| 4001 } | 9639 } |
| 4002 | 9640 |
| 4003 test_library() { | 9641 test_library() { |
| 4004 checkLibrary(''); | 9642 var library = checkLibrary(''); |
| 9643 if (isStrongMode) { |
| 9644 checkElementText( |
| 9645 library, |
| 9646 r''' |
| 9647 '''); |
| 9648 } else { |
| 9649 checkElementText( |
| 9650 library, |
| 9651 r''' |
| 9652 '''); |
| 9653 } |
| 4005 } | 9654 } |
| 4006 | 9655 |
| 4007 test_library_documented() { | 9656 test_library_documented() { |
| 4008 checkLibrary(''' | 9657 var library = checkLibrary(''' |
| 4009 // Extra comment so doc comment offset != 0 | 9658 // Extra comment so doc comment offset != 0 |
| 4010 /** | 9659 /** |
| 4011 * Docs | 9660 * Docs |
| 4012 */ | 9661 */ |
| 4013 library foo;'''); | 9662 library foo;'''); |
| 9663 if (isStrongMode) { |
| 9664 checkElementText( |
| 9665 library, |
| 9666 r''' |
| 9667 library foo; |
| 9668 '''); |
| 9669 } else { |
| 9670 checkElementText( |
| 9671 library, |
| 9672 r''' |
| 9673 library foo; |
| 9674 '''); |
| 9675 } |
| 4014 } | 9676 } |
| 4015 | 9677 |
| 4016 test_library_name_with_spaces() { | 9678 test_library_name_with_spaces() { |
| 4017 checkLibrary('library foo . bar ;'); | 9679 var library = checkLibrary('library foo . bar ;'); |
| 9680 if (isStrongMode) { |
| 9681 checkElementText( |
| 9682 library, |
| 9683 r''' |
| 9684 library foo.bar; |
| 9685 '''); |
| 9686 } else { |
| 9687 checkElementText( |
| 9688 library, |
| 9689 r''' |
| 9690 library foo.bar; |
| 9691 '''); |
| 9692 } |
| 4018 } | 9693 } |
| 4019 | 9694 |
| 4020 test_library_named() { | 9695 test_library_named() { |
| 4021 checkLibrary('library foo.bar;'); | 9696 var library = checkLibrary('library foo.bar;'); |
| 9697 if (isStrongMode) { |
| 9698 checkElementText( |
| 9699 library, |
| 9700 r''' |
| 9701 library foo.bar; |
| 9702 '''); |
| 9703 } else { |
| 9704 checkElementText( |
| 9705 library, |
| 9706 r''' |
| 9707 library foo.bar; |
| 9708 '''); |
| 9709 } |
| 4022 } | 9710 } |
| 4023 | 9711 |
| 4024 test_localFunctions() { | 9712 test_localFunctions() { |
| 4025 checkLibrary(r''' | 9713 var library = checkLibrary(r''' |
| 4026 f() { | 9714 f() { |
| 4027 f1() {} | 9715 f1() {} |
| 4028 { | 9716 { |
| 4029 f2() {} | 9717 f2() {} |
| 4030 } | 9718 } |
| 4031 } | 9719 } |
| 4032 '''); | 9720 '''); |
| 9721 if (isStrongMode) { |
| 9722 checkElementText( |
| 9723 library, |
| 9724 r''' |
| 9725 dynamic f() {} |
| 9726 '''); |
| 9727 } else { |
| 9728 checkElementText( |
| 9729 library, |
| 9730 r''' |
| 9731 dynamic f() {} |
| 9732 '''); |
| 9733 } |
| 4033 } | 9734 } |
| 4034 | 9735 |
| 4035 test_localFunctions_inConstructor() { | 9736 test_localFunctions_inConstructor() { |
| 4036 checkLibrary(r''' | 9737 var library = checkLibrary(r''' |
| 4037 class C { | 9738 class C { |
| 4038 C() { | 9739 C() { |
| 4039 f() {} | 9740 f() {} |
| 4040 } | 9741 } |
| 4041 } | 9742 } |
| 4042 '''); | 9743 '''); |
| 9744 if (isStrongMode) { |
| 9745 checkElementText( |
| 9746 library, |
| 9747 r''' |
| 9748 class C { |
| 9749 C(); |
| 9750 } |
| 9751 '''); |
| 9752 } else { |
| 9753 checkElementText( |
| 9754 library, |
| 9755 r''' |
| 9756 class C { |
| 9757 C(); |
| 9758 } |
| 9759 '''); |
| 9760 } |
| 4043 } | 9761 } |
| 4044 | 9762 |
| 4045 test_localFunctions_inMethod() { | 9763 test_localFunctions_inMethod() { |
| 4046 checkLibrary(r''' | 9764 var library = checkLibrary(r''' |
| 4047 class C { | 9765 class C { |
| 4048 m() { | 9766 m() { |
| 4049 f() {} | 9767 f() {} |
| 4050 } | 9768 } |
| 4051 } | 9769 } |
| 4052 '''); | 9770 '''); |
| 9771 if (isStrongMode) { |
| 9772 checkElementText( |
| 9773 library, |
| 9774 r''' |
| 9775 class C { |
| 9776 dynamic m() {} |
| 9777 } |
| 9778 '''); |
| 9779 } else { |
| 9780 checkElementText( |
| 9781 library, |
| 9782 r''' |
| 9783 class C { |
| 9784 dynamic m() {} |
| 9785 } |
| 9786 '''); |
| 9787 } |
| 4053 } | 9788 } |
| 4054 | 9789 |
| 4055 test_localFunctions_inTopLevelGetter() { | 9790 test_localFunctions_inTopLevelGetter() { |
| 4056 checkLibrary(r''' | 9791 var library = checkLibrary(r''' |
| 4057 get g { | 9792 get g { |
| 4058 f() {} | 9793 f() {} |
| 4059 } | 9794 } |
| 4060 '''); | 9795 '''); |
| 9796 if (isStrongMode) { |
| 9797 checkElementText( |
| 9798 library, |
| 9799 r''' |
| 9800 dynamic get g {} |
| 9801 '''); |
| 9802 } else { |
| 9803 checkElementText( |
| 9804 library, |
| 9805 r''' |
| 9806 dynamic get g {} |
| 9807 '''); |
| 9808 } |
| 4061 } | 9809 } |
| 4062 | 9810 |
| 4063 test_localLabels_inConstructor() { | 9811 test_localLabels_inConstructor() { |
| 4064 checkLibrary( | 9812 var library = checkLibrary( |
| 4065 r''' | 9813 r''' |
| 4066 class C { | 9814 class C { |
| 4067 C() { | 9815 C() { |
| 4068 aaa: while (true) {} | 9816 aaa: while (true) {} |
| 4069 bbb: switch (42) { | 9817 bbb: switch (42) { |
| 4070 ccc: case 0: | 9818 ccc: case 0: |
| 4071 break; | 9819 break; |
| 4072 } | 9820 } |
| 4073 } | 9821 } |
| 4074 } | 9822 } |
| 4075 ''', | 9823 ''', |
| 4076 allowErrors: true); | 9824 allowErrors: true); |
| 9825 if (isStrongMode) { |
| 9826 checkElementText( |
| 9827 library, |
| 9828 r''' |
| 9829 class C { |
| 9830 C(); |
| 9831 } |
| 9832 '''); |
| 9833 } else { |
| 9834 checkElementText( |
| 9835 library, |
| 9836 r''' |
| 9837 class C { |
| 9838 C(); |
| 9839 } |
| 9840 '''); |
| 9841 } |
| 4077 } | 9842 } |
| 4078 | 9843 |
| 4079 test_localLabels_inMethod() { | 9844 test_localLabels_inMethod() { |
| 4080 checkLibrary( | 9845 var library = checkLibrary( |
| 4081 r''' | 9846 r''' |
| 4082 class C { | 9847 class C { |
| 4083 m() { | 9848 m() { |
| 4084 aaa: while (true) {} | 9849 aaa: while (true) {} |
| 4085 bbb: switch (42) { | 9850 bbb: switch (42) { |
| 4086 ccc: case 0: | 9851 ccc: case 0: |
| 4087 break; | 9852 break; |
| 4088 } | 9853 } |
| 4089 } | 9854 } |
| 4090 } | 9855 } |
| 4091 ''', | 9856 ''', |
| 4092 allowErrors: true); | 9857 allowErrors: true); |
| 9858 if (isStrongMode) { |
| 9859 checkElementText( |
| 9860 library, |
| 9861 r''' |
| 9862 class C { |
| 9863 dynamic m() {} |
| 9864 } |
| 9865 '''); |
| 9866 } else { |
| 9867 checkElementText( |
| 9868 library, |
| 9869 r''' |
| 9870 class C { |
| 9871 dynamic m() {} |
| 9872 } |
| 9873 '''); |
| 9874 } |
| 4093 } | 9875 } |
| 4094 | 9876 |
| 4095 test_localLabels_inTopLevelFunction() { | 9877 test_localLabels_inTopLevelFunction() { |
| 4096 checkLibrary( | 9878 var library = checkLibrary( |
| 4097 r''' | 9879 r''' |
| 4098 main() { | 9880 main() { |
| 4099 aaa: while (true) {} | 9881 aaa: while (true) {} |
| 4100 bbb: switch (42) { | 9882 bbb: switch (42) { |
| 4101 ccc: case 0: | 9883 ccc: case 0: |
| 4102 break; | 9884 break; |
| 4103 } | 9885 } |
| 4104 } | 9886 } |
| 4105 ''', | 9887 ''', |
| 4106 allowErrors: true); | 9888 allowErrors: true); |
| 9889 if (isStrongMode) { |
| 9890 checkElementText( |
| 9891 library, |
| 9892 r''' |
| 9893 dynamic main() {} |
| 9894 '''); |
| 9895 } else { |
| 9896 checkElementText( |
| 9897 library, |
| 9898 r''' |
| 9899 dynamic main() {} |
| 9900 '''); |
| 9901 } |
| 4107 } | 9902 } |
| 4108 | 9903 |
| 4109 test_localVariables_inConstructor() { | 9904 test_localVariables_inConstructor() { |
| 4110 checkLibrary(r''' | 9905 var library = checkLibrary(r''' |
| 4111 class C { | 9906 class C { |
| 4112 C() { | 9907 C() { |
| 4113 int v; | 9908 int v; |
| 4114 f() {} | 9909 f() {} |
| 4115 } | 9910 } |
| 4116 } | 9911 } |
| 4117 '''); | 9912 '''); |
| 9913 if (isStrongMode) { |
| 9914 checkElementText( |
| 9915 library, |
| 9916 r''' |
| 9917 class C { |
| 9918 C(); |
| 9919 } |
| 9920 '''); |
| 9921 } else { |
| 9922 checkElementText( |
| 9923 library, |
| 9924 r''' |
| 9925 class C { |
| 9926 C(); |
| 9927 } |
| 9928 '''); |
| 9929 } |
| 4118 } | 9930 } |
| 4119 | 9931 |
| 4120 test_localVariables_inLocalFunction() { | 9932 test_localVariables_inLocalFunction() { |
| 4121 checkLibrary(r''' | 9933 var library = checkLibrary(r''' |
| 4122 f() { | 9934 f() { |
| 4123 f1() { | 9935 f1() { |
| 4124 int v1 = 1; | 9936 int v1 = 1; |
| 4125 } // 2 | 9937 } // 2 |
| 4126 f2() { | 9938 f2() { |
| 4127 int v1 = 1; | 9939 int v1 = 1; |
| 4128 f3() { | 9940 f3() { |
| 4129 int v2 = 1; | 9941 int v2 = 1; |
| 4130 } | 9942 } |
| 4131 } | 9943 } |
| 4132 } | 9944 } |
| 4133 '''); | 9945 '''); |
| 9946 if (isStrongMode) { |
| 9947 checkElementText( |
| 9948 library, |
| 9949 r''' |
| 9950 dynamic f() {} |
| 9951 '''); |
| 9952 } else { |
| 9953 checkElementText( |
| 9954 library, |
| 9955 r''' |
| 9956 dynamic f() {} |
| 9957 '''); |
| 9958 } |
| 4134 } | 9959 } |
| 4135 | 9960 |
| 4136 test_localVariables_inMethod() { | 9961 test_localVariables_inMethod() { |
| 4137 checkLibrary(r''' | 9962 var library = checkLibrary(r''' |
| 4138 class C { | 9963 class C { |
| 4139 m() { | 9964 m() { |
| 4140 int v; | 9965 int v; |
| 4141 } | 9966 } |
| 4142 } | 9967 } |
| 4143 '''); | 9968 '''); |
| 9969 if (isStrongMode) { |
| 9970 checkElementText( |
| 9971 library, |
| 9972 r''' |
| 9973 class C { |
| 9974 dynamic m() {} |
| 9975 } |
| 9976 '''); |
| 9977 } else { |
| 9978 checkElementText( |
| 9979 library, |
| 9980 r''' |
| 9981 class C { |
| 9982 dynamic m() {} |
| 9983 } |
| 9984 '''); |
| 9985 } |
| 4144 } | 9986 } |
| 4145 | 9987 |
| 4146 test_localVariables_inTopLevelFunction() { | 9988 test_localVariables_inTopLevelFunction() { |
| 4147 checkLibrary(r''' | 9989 var library = checkLibrary(r''' |
| 4148 main() { | 9990 main() { |
| 4149 int v1 = 1; | 9991 int v1 = 1; |
| 4150 { | 9992 { |
| 4151 const String v2 = 'bbb'; | 9993 const String v2 = 'bbb'; |
| 4152 } | 9994 } |
| 4153 Map<int, List<double>> v3; | 9995 Map<int, List<double>> v3; |
| 4154 } | 9996 } |
| 4155 '''); | 9997 '''); |
| 9998 if (isStrongMode) { |
| 9999 checkElementText( |
| 10000 library, |
| 10001 r''' |
| 10002 dynamic main() {} |
| 10003 '''); |
| 10004 } else { |
| 10005 checkElementText( |
| 10006 library, |
| 10007 r''' |
| 10008 dynamic main() {} |
| 10009 '''); |
| 10010 } |
| 4156 } | 10011 } |
| 4157 | 10012 |
| 4158 test_localVariables_inTopLevelGetter() { | 10013 test_localVariables_inTopLevelGetter() { |
| 4159 checkLibrary(r''' | 10014 var library = checkLibrary(r''' |
| 4160 get g { | 10015 get g { |
| 4161 int v; | 10016 int v; |
| 4162 } | 10017 } |
| 4163 '''); | 10018 '''); |
| 10019 if (isStrongMode) { |
| 10020 checkElementText( |
| 10021 library, |
| 10022 r''' |
| 10023 dynamic get g {} |
| 10024 '''); |
| 10025 } else { |
| 10026 checkElementText( |
| 10027 library, |
| 10028 r''' |
| 10029 dynamic get g {} |
| 10030 '''); |
| 10031 } |
| 4164 } | 10032 } |
| 4165 | 10033 |
| 4166 test_main_class() { | 10034 test_main_class() { |
| 4167 checkLibrary('class main {}'); | 10035 var library = checkLibrary('class main {}'); |
| 10036 if (isStrongMode) { |
| 10037 checkElementText( |
| 10038 library, |
| 10039 r''' |
| 10040 class main { |
| 10041 } |
| 10042 '''); |
| 10043 } else { |
| 10044 checkElementText( |
| 10045 library, |
| 10046 r''' |
| 10047 class main { |
| 10048 } |
| 10049 '''); |
| 10050 } |
| 4168 } | 10051 } |
| 4169 | 10052 |
| 4170 test_main_class_alias() { | 10053 test_main_class_alias() { |
| 4171 checkLibrary('class main = C with D; class C {} class D {}'); | 10054 var library = checkLibrary('class main = C with D; class C {} class D {}'); |
| 10055 if (isStrongMode) { |
| 10056 checkElementText( |
| 10057 library, |
| 10058 r''' |
| 10059 class alias main extends C with D { |
| 10060 synthetic main() = C; |
| 10061 } |
| 10062 class C { |
| 10063 } |
| 10064 class D { |
| 10065 } |
| 10066 '''); |
| 10067 } else { |
| 10068 checkElementText( |
| 10069 library, |
| 10070 r''' |
| 10071 class alias main extends C with D { |
| 10072 synthetic main() = C; |
| 10073 } |
| 10074 class C { |
| 10075 } |
| 10076 class D { |
| 10077 } |
| 10078 '''); |
| 10079 } |
| 4172 } | 10080 } |
| 4173 | 10081 |
| 4174 test_main_class_alias_via_export() { | 10082 test_main_class_alias_via_export() { |
| 4175 addLibrarySource('/a.dart', 'class main = C with D; class C {} class D {}'); | 10083 addLibrarySource('/a.dart', 'class main = C with D; class C {} class D {}'); |
| 4176 checkLibrary('export "a.dart";'); | 10084 var library = checkLibrary('export "a.dart";'); |
| 10085 if (isStrongMode) { |
| 10086 checkElementText( |
| 10087 library, |
| 10088 r''' |
| 10089 export 'a.dart'; |
| 10090 '''); |
| 10091 } else { |
| 10092 checkElementText( |
| 10093 library, |
| 10094 r''' |
| 10095 export 'a.dart'; |
| 10096 '''); |
| 10097 } |
| 4177 } | 10098 } |
| 4178 | 10099 |
| 4179 test_main_class_via_export() { | 10100 test_main_class_via_export() { |
| 4180 addLibrarySource('/a.dart', 'class main {}'); | 10101 addLibrarySource('/a.dart', 'class main {}'); |
| 4181 checkLibrary('export "a.dart";'); | 10102 var library = checkLibrary('export "a.dart";'); |
| 10103 if (isStrongMode) { |
| 10104 checkElementText( |
| 10105 library, |
| 10106 r''' |
| 10107 export 'a.dart'; |
| 10108 '''); |
| 10109 } else { |
| 10110 checkElementText( |
| 10111 library, |
| 10112 r''' |
| 10113 export 'a.dart'; |
| 10114 '''); |
| 10115 } |
| 4182 } | 10116 } |
| 4183 | 10117 |
| 4184 test_main_getter() { | 10118 test_main_getter() { |
| 4185 checkLibrary('get main => null;'); | 10119 var library = checkLibrary('get main => null;'); |
| 10120 if (isStrongMode) { |
| 10121 checkElementText( |
| 10122 library, |
| 10123 r''' |
| 10124 dynamic get main {} |
| 10125 '''); |
| 10126 } else { |
| 10127 checkElementText( |
| 10128 library, |
| 10129 r''' |
| 10130 dynamic get main {} |
| 10131 '''); |
| 10132 } |
| 4186 } | 10133 } |
| 4187 | 10134 |
| 4188 test_main_getter_via_export() { | 10135 test_main_getter_via_export() { |
| 4189 addLibrarySource('/a.dart', 'get main => null;'); | 10136 addLibrarySource('/a.dart', 'get main => null;'); |
| 4190 checkLibrary('export "a.dart";'); | 10137 var library = checkLibrary('export "a.dart";'); |
| 10138 if (isStrongMode) { |
| 10139 checkElementText( |
| 10140 library, |
| 10141 r''' |
| 10142 export 'a.dart'; |
| 10143 '''); |
| 10144 } else { |
| 10145 checkElementText( |
| 10146 library, |
| 10147 r''' |
| 10148 export 'a.dart'; |
| 10149 '''); |
| 10150 } |
| 4191 } | 10151 } |
| 4192 | 10152 |
| 4193 test_main_typedef() { | 10153 test_main_typedef() { |
| 4194 checkLibrary('typedef main();'); | 10154 var library = checkLibrary('typedef main();'); |
| 10155 if (isStrongMode) { |
| 10156 checkElementText( |
| 10157 library, |
| 10158 r''' |
| 10159 typedef dynamic main(); |
| 10160 '''); |
| 10161 } else { |
| 10162 checkElementText( |
| 10163 library, |
| 10164 r''' |
| 10165 typedef dynamic main(); |
| 10166 '''); |
| 10167 } |
| 4195 } | 10168 } |
| 4196 | 10169 |
| 4197 test_main_typedef_via_export() { | 10170 test_main_typedef_via_export() { |
| 4198 addLibrarySource('/a.dart', 'typedef main();'); | 10171 addLibrarySource('/a.dart', 'typedef main();'); |
| 4199 checkLibrary('export "a.dart";'); | 10172 var library = checkLibrary('export "a.dart";'); |
| 10173 if (isStrongMode) { |
| 10174 checkElementText( |
| 10175 library, |
| 10176 r''' |
| 10177 export 'a.dart'; |
| 10178 '''); |
| 10179 } else { |
| 10180 checkElementText( |
| 10181 library, |
| 10182 r''' |
| 10183 export 'a.dart'; |
| 10184 '''); |
| 10185 } |
| 4200 } | 10186 } |
| 4201 | 10187 |
| 4202 test_main_variable() { | 10188 test_main_variable() { |
| 4203 checkLibrary('var main;'); | 10189 var library = checkLibrary('var main;'); |
| 10190 if (isStrongMode) { |
| 10191 checkElementText( |
| 10192 library, |
| 10193 r''' |
| 10194 dynamic main; |
| 10195 '''); |
| 10196 } else { |
| 10197 checkElementText( |
| 10198 library, |
| 10199 r''' |
| 10200 dynamic main; |
| 10201 '''); |
| 10202 } |
| 4204 } | 10203 } |
| 4205 | 10204 |
| 4206 test_main_variable_via_export() { | 10205 test_main_variable_via_export() { |
| 4207 addLibrarySource('/a.dart', 'var main;'); | 10206 addLibrarySource('/a.dart', 'var main;'); |
| 4208 checkLibrary('export "a.dart";'); | 10207 var library = checkLibrary('export "a.dart";'); |
| 10208 if (isStrongMode) { |
| 10209 checkElementText( |
| 10210 library, |
| 10211 r''' |
| 10212 export 'a.dart'; |
| 10213 '''); |
| 10214 } else { |
| 10215 checkElementText( |
| 10216 library, |
| 10217 r''' |
| 10218 export 'a.dart'; |
| 10219 '''); |
| 10220 } |
| 4209 } | 10221 } |
| 4210 | 10222 |
| 4211 test_member_function_async() { | 10223 test_member_function_async() { |
| 4212 checkLibrary(r''' | 10224 var library = checkLibrary(r''' |
| 4213 import 'dart:async'; | 10225 import 'dart:async'; |
| 4214 class C { | 10226 class C { |
| 4215 Future f() async {} | 10227 Future f() async {} |
| 4216 } | 10228 } |
| 4217 '''); | 10229 '''); |
| 10230 if (isStrongMode) { |
| 10231 checkElementText( |
| 10232 library, |
| 10233 r''' |
| 10234 import 'dart:async'; |
| 10235 class C { |
| 10236 Future<dynamic> f() async {} |
| 10237 } |
| 10238 '''); |
| 10239 } else { |
| 10240 checkElementText( |
| 10241 library, |
| 10242 r''' |
| 10243 import 'dart:async'; |
| 10244 class C { |
| 10245 Future<dynamic> f() async {} |
| 10246 } |
| 10247 '''); |
| 10248 } |
| 4218 } | 10249 } |
| 4219 | 10250 |
| 4220 test_member_function_asyncStar() { | 10251 test_member_function_asyncStar() { |
| 4221 checkLibrary(r''' | 10252 var library = checkLibrary(r''' |
| 4222 import 'dart:async'; | 10253 import 'dart:async'; |
| 4223 class C { | 10254 class C { |
| 4224 Stream f() async* {} | 10255 Stream f() async* {} |
| 4225 } | 10256 } |
| 4226 '''); | 10257 '''); |
| 10258 if (isStrongMode) { |
| 10259 checkElementText( |
| 10260 library, |
| 10261 r''' |
| 10262 import 'dart:async'; |
| 10263 class C { |
| 10264 Stream<dynamic> f() async* {} |
| 10265 } |
| 10266 '''); |
| 10267 } else { |
| 10268 checkElementText( |
| 10269 library, |
| 10270 r''' |
| 10271 import 'dart:async'; |
| 10272 class C { |
| 10273 Stream<dynamic> f() async* {} |
| 10274 } |
| 10275 '''); |
| 10276 } |
| 4227 } | 10277 } |
| 4228 | 10278 |
| 4229 test_metadata_classDeclaration() { | 10279 test_metadata_classDeclaration() { |
| 4230 checkLibrary('const a = null; @a class C {}'); | 10280 var library = checkLibrary(r''' |
| 10281 const a = null; |
| 10282 const b = null; |
| 10283 @a |
| 10284 @b |
| 10285 class C {}'''); |
| 10286 if (isStrongMode) { |
| 10287 checkElementText( |
| 10288 library, |
| 10289 r''' |
| 10290 @a |
| 10291 @b |
| 10292 class C { |
| 10293 } |
| 10294 const dynamic a = null; |
| 10295 const dynamic b = null; |
| 10296 '''); |
| 10297 } else { |
| 10298 checkElementText( |
| 10299 library, |
| 10300 r''' |
| 10301 @a |
| 10302 @b |
| 10303 class C { |
| 10304 } |
| 10305 const dynamic a = null; |
| 10306 const dynamic b = null; |
| 10307 '''); |
| 10308 } |
| 4231 } | 10309 } |
| 4232 | 10310 |
| 4233 test_metadata_classTypeAlias() { | 10311 test_metadata_classTypeAlias() { |
| 4234 checkLibrary( | 10312 var library = checkLibrary( |
| 4235 'const a = null; @a class C = D with E; class D {} class E {}'); | 10313 'const a = null; @a class C = D with E; class D {} class E {}'); |
| 10314 if (isStrongMode) { |
| 10315 checkElementText( |
| 10316 library, |
| 10317 r''' |
| 10318 @a |
| 10319 class alias C extends D with E { |
| 10320 synthetic C() = D; |
| 10321 } |
| 10322 class D { |
| 10323 } |
| 10324 class E { |
| 10325 } |
| 10326 const dynamic a = null; |
| 10327 '''); |
| 10328 } else { |
| 10329 checkElementText( |
| 10330 library, |
| 10331 r''' |
| 10332 @a |
| 10333 class alias C extends D with E { |
| 10334 synthetic C() = D; |
| 10335 } |
| 10336 class D { |
| 10337 } |
| 10338 class E { |
| 10339 } |
| 10340 const dynamic a = null; |
| 10341 '''); |
| 10342 } |
| 4236 } | 10343 } |
| 4237 | 10344 |
| 4238 test_metadata_constructor_call_named() { | 10345 test_metadata_constructor_call_named() { |
| 4239 checkLibrary('class A { const A.named(); } @A.named() class C {}'); | 10346 var library = |
| 10347 checkLibrary('class A { const A.named(); } @A.named() class C {}'); |
| 10348 if (isStrongMode) { |
| 10349 checkElementText( |
| 10350 library, |
| 10351 r''' |
| 10352 class A { |
| 10353 const A.named(); |
| 10354 } |
| 10355 @A.named() |
| 10356 class C { |
| 10357 } |
| 10358 '''); |
| 10359 } else { |
| 10360 checkElementText( |
| 10361 library, |
| 10362 r''' |
| 10363 class A { |
| 10364 const A.named(); |
| 10365 } |
| 10366 @A.named() |
| 10367 class C { |
| 10368 } |
| 10369 '''); |
| 10370 } |
| 4240 } | 10371 } |
| 4241 | 10372 |
| 4242 test_metadata_constructor_call_named_prefixed() { | 10373 test_metadata_constructor_call_named_prefixed() { |
| 4243 addLibrarySource('/foo.dart', 'class A { const A.named(); }'); | 10374 addLibrarySource('/foo.dart', 'class A { const A.named(); }'); |
| 4244 checkLibrary('import "foo.dart" as foo; @foo.A.named() class C {}'); | 10375 var library = |
| 10376 checkLibrary('import "foo.dart" as foo; @foo.A.named() class C {}'); |
| 10377 if (isStrongMode) { |
| 10378 checkElementText( |
| 10379 library, |
| 10380 r''' |
| 10381 import 'foo.dart' as foo; |
| 10382 @A.named() |
| 10383 class C { |
| 10384 } |
| 10385 '''); |
| 10386 } else { |
| 10387 checkElementText( |
| 10388 library, |
| 10389 r''' |
| 10390 import 'foo.dart' as foo; |
| 10391 @A.named() |
| 10392 class C { |
| 10393 } |
| 10394 '''); |
| 10395 } |
| 4245 } | 10396 } |
| 4246 | 10397 |
| 4247 test_metadata_constructor_call_unnamed() { | 10398 test_metadata_constructor_call_unnamed() { |
| 4248 checkLibrary('class A { const A(); } @A() class C {}'); | 10399 var library = checkLibrary('class A { const A(); } @A() class C {}'); |
| 10400 if (isStrongMode) { |
| 10401 checkElementText( |
| 10402 library, |
| 10403 r''' |
| 10404 class A { |
| 10405 const A(); |
| 10406 } |
| 10407 @A() |
| 10408 class C { |
| 10409 } |
| 10410 '''); |
| 10411 } else { |
| 10412 checkElementText( |
| 10413 library, |
| 10414 r''' |
| 10415 class A { |
| 10416 const A(); |
| 10417 } |
| 10418 @A() |
| 10419 class C { |
| 10420 } |
| 10421 '''); |
| 10422 } |
| 4249 } | 10423 } |
| 4250 | 10424 |
| 4251 test_metadata_constructor_call_unnamed_prefixed() { | 10425 test_metadata_constructor_call_unnamed_prefixed() { |
| 4252 addLibrarySource('/foo.dart', 'class A { const A(); }'); | 10426 addLibrarySource('/foo.dart', 'class A { const A(); }'); |
| 4253 checkLibrary('import "foo.dart" as foo; @foo.A() class C {}'); | 10427 var library = checkLibrary('import "foo.dart" as foo; @foo.A() class C {}'); |
| 10428 if (isStrongMode) { |
| 10429 checkElementText( |
| 10430 library, |
| 10431 r''' |
| 10432 import 'foo.dart' as foo; |
| 10433 @A() |
| 10434 class C { |
| 10435 } |
| 10436 '''); |
| 10437 } else { |
| 10438 checkElementText( |
| 10439 library, |
| 10440 r''' |
| 10441 import 'foo.dart' as foo; |
| 10442 @A() |
| 10443 class C { |
| 10444 } |
| 10445 '''); |
| 10446 } |
| 4254 } | 10447 } |
| 4255 | 10448 |
| 4256 test_metadata_constructor_call_with_args() { | 10449 test_metadata_constructor_call_with_args() { |
| 4257 checkLibrary('class A { const A(x); } @A(null) class C {}'); | 10450 var library = checkLibrary('class A { const A(x); } @A(null) class C {}'); |
| 10451 if (isStrongMode) { |
| 10452 checkElementText( |
| 10453 library, |
| 10454 r''' |
| 10455 class A { |
| 10456 const A(dynamic x); |
| 10457 } |
| 10458 @A(null) |
| 10459 class C { |
| 10460 } |
| 10461 '''); |
| 10462 } else { |
| 10463 checkElementText( |
| 10464 library, |
| 10465 r''' |
| 10466 class A { |
| 10467 const A(dynamic x); |
| 10468 } |
| 10469 @A(null) |
| 10470 class C { |
| 10471 } |
| 10472 '''); |
| 10473 } |
| 4258 } | 10474 } |
| 4259 | 10475 |
| 4260 test_metadata_constructorDeclaration_named() { | 10476 test_metadata_constructorDeclaration_named() { |
| 4261 checkLibrary('const a = null; class C { @a C.named(); }'); | 10477 var library = checkLibrary('const a = null; class C { @a C.named(); }'); |
| 10478 if (isStrongMode) { |
| 10479 checkElementText( |
| 10480 library, |
| 10481 r''' |
| 10482 class C { |
| 10483 @a |
| 10484 C.named(); |
| 10485 } |
| 10486 const dynamic a = null; |
| 10487 '''); |
| 10488 } else { |
| 10489 checkElementText( |
| 10490 library, |
| 10491 r''' |
| 10492 class C { |
| 10493 @a |
| 10494 C.named(); |
| 10495 } |
| 10496 const dynamic a = null; |
| 10497 '''); |
| 10498 } |
| 4262 } | 10499 } |
| 4263 | 10500 |
| 4264 test_metadata_constructorDeclaration_unnamed() { | 10501 test_metadata_constructorDeclaration_unnamed() { |
| 4265 checkLibrary('const a = null; class C { @a C(); }'); | 10502 var library = checkLibrary('const a = null; class C { @a C(); }'); |
| 10503 if (isStrongMode) { |
| 10504 checkElementText( |
| 10505 library, |
| 10506 r''' |
| 10507 class C { |
| 10508 @a |
| 10509 C(); |
| 10510 } |
| 10511 const dynamic a = null; |
| 10512 '''); |
| 10513 } else { |
| 10514 checkElementText( |
| 10515 library, |
| 10516 r''' |
| 10517 class C { |
| 10518 @a |
| 10519 C(); |
| 10520 } |
| 10521 const dynamic a = null; |
| 10522 '''); |
| 10523 } |
| 4266 } | 10524 } |
| 4267 | 10525 |
| 4268 test_metadata_enumDeclaration() { | 10526 test_metadata_enumDeclaration() { |
| 4269 checkLibrary('const a = null; @a enum E { v }'); | 10527 var library = checkLibrary('const a = null; @a enum E { v }'); |
| 10528 if (isStrongMode) { |
| 10529 checkElementText( |
| 10530 library, |
| 10531 r''' |
| 10532 @a |
| 10533 enum E { |
| 10534 final int index; |
| 10535 static const List<E> values; |
| 10536 static const E v; |
| 10537 } |
| 10538 const dynamic a = null; |
| 10539 '''); |
| 10540 } else { |
| 10541 checkElementText( |
| 10542 library, |
| 10543 r''' |
| 10544 @a |
| 10545 enum E { |
| 10546 final int index; |
| 10547 static const List<E> values; |
| 10548 static const E v; |
| 10549 } |
| 10550 const dynamic a = null; |
| 10551 '''); |
| 10552 } |
| 4270 } | 10553 } |
| 4271 | 10554 |
| 4272 test_metadata_exportDirective() { | 10555 test_metadata_exportDirective() { |
| 4273 addLibrarySource('/foo.dart', ''); | 10556 addLibrarySource('/foo.dart', ''); |
| 4274 checkLibrary('@a export "foo.dart"; const a = null;'); | 10557 var library = checkLibrary('@a export "foo.dart"; const a = null;'); |
| 10558 if (isStrongMode) { |
| 10559 checkElementText( |
| 10560 library, |
| 10561 r''' |
| 10562 @a |
| 10563 export 'foo.dart'; |
| 10564 const dynamic a = null; |
| 10565 '''); |
| 10566 } else { |
| 10567 checkElementText( |
| 10568 library, |
| 10569 r''' |
| 10570 @a |
| 10571 export 'foo.dart'; |
| 10572 const dynamic a = null; |
| 10573 '''); |
| 10574 } |
| 4275 } | 10575 } |
| 4276 | 10576 |
| 4277 test_metadata_fieldDeclaration() { | 10577 test_metadata_fieldDeclaration() { |
| 4278 checkLibrary('const a = null; class C { @a int x; }'); | 10578 var library = checkLibrary('const a = null; class C { @a int x; }'); |
| 10579 if (isStrongMode) { |
| 10580 checkElementText( |
| 10581 library, |
| 10582 r''' |
| 10583 class C { |
| 10584 @a |
| 10585 int x; |
| 10586 } |
| 10587 const dynamic a = null; |
| 10588 '''); |
| 10589 } else { |
| 10590 checkElementText( |
| 10591 library, |
| 10592 r''' |
| 10593 class C { |
| 10594 @a |
| 10595 int x; |
| 10596 } |
| 10597 const dynamic a = null; |
| 10598 '''); |
| 10599 } |
| 4279 } | 10600 } |
| 4280 | 10601 |
| 4281 test_metadata_fieldFormalParameter() { | 10602 test_metadata_fieldFormalParameter() { |
| 4282 checkLibrary('const a = null; class C { var x; C(@a this.x); }'); | 10603 var library = |
| 10604 checkLibrary('const a = null; class C { var x; C(@a this.x); }'); |
| 10605 if (isStrongMode) { |
| 10606 checkElementText( |
| 10607 library, |
| 10608 r''' |
| 10609 class C { |
| 10610 dynamic x; |
| 10611 C(@a dynamic this.x); |
| 10612 } |
| 10613 const dynamic a = null; |
| 10614 '''); |
| 10615 } else { |
| 10616 checkElementText( |
| 10617 library, |
| 10618 r''' |
| 10619 class C { |
| 10620 dynamic x; |
| 10621 C(@a dynamic this.x); |
| 10622 } |
| 10623 const dynamic a = null; |
| 10624 '''); |
| 10625 } |
| 4283 } | 10626 } |
| 4284 | 10627 |
| 4285 test_metadata_fieldFormalParameter_withDefault() { | 10628 test_metadata_fieldFormalParameter_withDefault() { |
| 4286 checkLibrary('const a = null; class C { var x; C([@a this.x = null]); }'); | 10629 var library = checkLibrary( |
| 10630 'const a = null; class C { var x; C([@a this.x = null]); }'); |
| 10631 if (isStrongMode) { |
| 10632 checkElementText( |
| 10633 library, |
| 10634 r''' |
| 10635 class C { |
| 10636 dynamic x; |
| 10637 C([@a dynamic this.x]); |
| 10638 } |
| 10639 const dynamic a = null; |
| 10640 '''); |
| 10641 } else { |
| 10642 checkElementText( |
| 10643 library, |
| 10644 r''' |
| 10645 class C { |
| 10646 dynamic x; |
| 10647 C([@a dynamic this.x]); |
| 10648 } |
| 10649 const dynamic a = null; |
| 10650 '''); |
| 10651 } |
| 4287 } | 10652 } |
| 4288 | 10653 |
| 4289 test_metadata_functionDeclaration_function() { | 10654 test_metadata_functionDeclaration_function() { |
| 4290 checkLibrary('const a = null; @a f() {}'); | 10655 var library = checkLibrary('const a = null; @a f() {}'); |
| 10656 if (isStrongMode) { |
| 10657 checkElementText( |
| 10658 library, |
| 10659 r''' |
| 10660 const dynamic a = null; |
| 10661 dynamic f() {} |
| 10662 '''); |
| 10663 } else { |
| 10664 checkElementText( |
| 10665 library, |
| 10666 r''' |
| 10667 const dynamic a = null; |
| 10668 dynamic f() {} |
| 10669 '''); |
| 10670 } |
| 4291 } | 10671 } |
| 4292 | 10672 |
| 4293 test_metadata_functionDeclaration_getter() { | 10673 test_metadata_functionDeclaration_getter() { |
| 4294 checkLibrary('const a = null; @a get f => null;'); | 10674 var library = checkLibrary('const a = null; @a get f => null;'); |
| 10675 if (isStrongMode) { |
| 10676 checkElementText( |
| 10677 library, |
| 10678 r''' |
| 10679 const dynamic a = null; |
| 10680 @a |
| 10681 dynamic get f {} |
| 10682 '''); |
| 10683 } else { |
| 10684 checkElementText( |
| 10685 library, |
| 10686 r''' |
| 10687 const dynamic a = null; |
| 10688 @a |
| 10689 dynamic get f {} |
| 10690 '''); |
| 10691 } |
| 4295 } | 10692 } |
| 4296 | 10693 |
| 4297 test_metadata_functionDeclaration_setter() { | 10694 test_metadata_functionDeclaration_setter() { |
| 4298 checkLibrary('const a = null; @a set f(value) {}'); | 10695 var library = checkLibrary('const a = null; @a set f(value) {}'); |
| 10696 if (isStrongMode) { |
| 10697 checkElementText( |
| 10698 library, |
| 10699 r''' |
| 10700 const dynamic a = null; |
| 10701 @a |
| 10702 void set f(dynamic value) {} |
| 10703 '''); |
| 10704 } else { |
| 10705 checkElementText( |
| 10706 library, |
| 10707 r''' |
| 10708 const dynamic a = null; |
| 10709 @a |
| 10710 dynamic set f(dynamic value) {} |
| 10711 '''); |
| 10712 } |
| 4299 } | 10713 } |
| 4300 | 10714 |
| 4301 test_metadata_functionTypeAlias() { | 10715 test_metadata_functionTypeAlias() { |
| 4302 checkLibrary('const a = null; @a typedef F();'); | 10716 var library = checkLibrary('const a = null; @a typedef F();'); |
| 10717 if (isStrongMode) { |
| 10718 checkElementText( |
| 10719 library, |
| 10720 r''' |
| 10721 @a |
| 10722 typedef dynamic F(); |
| 10723 const dynamic a = null; |
| 10724 '''); |
| 10725 } else { |
| 10726 checkElementText( |
| 10727 library, |
| 10728 r''' |
| 10729 @a |
| 10730 typedef dynamic F(); |
| 10731 const dynamic a = null; |
| 10732 '''); |
| 10733 } |
| 4303 } | 10734 } |
| 4304 | 10735 |
| 4305 test_metadata_functionTypedFormalParameter() { | 10736 test_metadata_functionTypedFormalParameter() { |
| 4306 checkLibrary('const a = null; f(@a g()) {}'); | 10737 var library = checkLibrary('const a = null; f(@a g()) {}'); |
| 10738 if (isStrongMode) { |
| 10739 checkElementText( |
| 10740 library, |
| 10741 r''' |
| 10742 const dynamic a = null; |
| 10743 dynamic f(@a () → dynamic g) {} |
| 10744 '''); |
| 10745 } else { |
| 10746 checkElementText( |
| 10747 library, |
| 10748 r''' |
| 10749 const dynamic a = null; |
| 10750 dynamic f(@a () → dynamic g) {} |
| 10751 '''); |
| 10752 } |
| 4307 } | 10753 } |
| 4308 | 10754 |
| 4309 test_metadata_functionTypedFormalParameter_withDefault() { | 10755 test_metadata_functionTypedFormalParameter_withDefault() { |
| 4310 checkLibrary('const a = null; f([@a g() = null]) {}'); | 10756 var library = checkLibrary('const a = null; f([@a g() = null]) {}'); |
| 10757 if (isStrongMode) { |
| 10758 checkElementText( |
| 10759 library, |
| 10760 r''' |
| 10761 const dynamic a = null; |
| 10762 dynamic f([@a () → dynamic g = null]) {} |
| 10763 '''); |
| 10764 } else { |
| 10765 checkElementText( |
| 10766 library, |
| 10767 r''' |
| 10768 const dynamic a = null; |
| 10769 dynamic f([@a () → dynamic g = null]) {} |
| 10770 '''); |
| 10771 } |
| 4311 } | 10772 } |
| 4312 | 10773 |
| 4313 test_metadata_importDirective() { | 10774 test_metadata_importDirective() { |
| 4314 addLibrarySource('/foo.dart', 'const b = null;'); | 10775 addLibrarySource('/foo.dart', 'const b = null;'); |
| 4315 checkLibrary('@a import "foo.dart"; const a = b;'); | 10776 var library = checkLibrary('@a import "foo.dart"; const a = b;'); |
| 10777 if (isStrongMode) { |
| 10778 checkElementText( |
| 10779 library, |
| 10780 r''' |
| 10781 @a |
| 10782 import 'foo.dart'; |
| 10783 const dynamic a = b; |
| 10784 '''); |
| 10785 } else { |
| 10786 checkElementText( |
| 10787 library, |
| 10788 r''' |
| 10789 @a |
| 10790 import 'foo.dart'; |
| 10791 const dynamic a = b; |
| 10792 '''); |
| 10793 } |
| 4316 } | 10794 } |
| 4317 | 10795 |
| 4318 test_metadata_invalid_classDeclaration() { | 10796 test_metadata_invalid_classDeclaration() { |
| 4319 checkLibrary('f(_) {} @f(42) class C {}'); | 10797 var library = checkLibrary('f(_) {} @f(42) class C {}'); |
| 10798 if (isStrongMode) { |
| 10799 checkElementText( |
| 10800 library, |
| 10801 r''' |
| 10802 @f(42) |
| 10803 class C { |
| 10804 } |
| 10805 dynamic f(dynamic _) {} |
| 10806 '''); |
| 10807 } else { |
| 10808 checkElementText( |
| 10809 library, |
| 10810 r''' |
| 10811 @f(42) |
| 10812 class C { |
| 10813 } |
| 10814 dynamic f(dynamic _) {} |
| 10815 '''); |
| 10816 } |
| 4320 } | 10817 } |
| 4321 | 10818 |
| 4322 test_metadata_libraryDirective() { | 10819 test_metadata_libraryDirective() { |
| 4323 checkLibrary('@a library L; const a = null;'); | 10820 var library = checkLibrary('@a library L; const a = null;'); |
| 10821 if (isStrongMode) { |
| 10822 checkElementText( |
| 10823 library, |
| 10824 r''' |
| 10825 @a |
| 10826 library L; |
| 10827 const dynamic a = null; |
| 10828 '''); |
| 10829 } else { |
| 10830 checkElementText( |
| 10831 library, |
| 10832 r''' |
| 10833 @a |
| 10834 library L; |
| 10835 const dynamic a = null; |
| 10836 '''); |
| 10837 } |
| 4324 } | 10838 } |
| 4325 | 10839 |
| 4326 test_metadata_methodDeclaration_getter() { | 10840 test_metadata_methodDeclaration_getter() { |
| 4327 checkLibrary('const a = null; class C { @a get m => null; }'); | 10841 var library = checkLibrary('const a = null; class C { @a get m => null; }'); |
| 10842 if (isStrongMode) { |
| 10843 checkElementText( |
| 10844 library, |
| 10845 r''' |
| 10846 class C { |
| 10847 @a |
| 10848 dynamic get m {} |
| 10849 } |
| 10850 const dynamic a = null; |
| 10851 '''); |
| 10852 } else { |
| 10853 checkElementText( |
| 10854 library, |
| 10855 r''' |
| 10856 class C { |
| 10857 @a |
| 10858 dynamic get m {} |
| 10859 } |
| 10860 const dynamic a = null; |
| 10861 '''); |
| 10862 } |
| 4328 } | 10863 } |
| 4329 | 10864 |
| 4330 test_metadata_methodDeclaration_method() { | 10865 test_metadata_methodDeclaration_method() { |
| 4331 checkLibrary('const a = null; class C { @a m() {} }'); | 10866 var library = checkLibrary(r''' |
| 10867 const a = null; |
| 10868 const b = null; |
| 10869 class C { |
| 10870 @a |
| 10871 @b |
| 10872 m() {} |
| 10873 } |
| 10874 '''); |
| 10875 if (isStrongMode) { |
| 10876 checkElementText( |
| 10877 library, |
| 10878 r''' |
| 10879 class C { |
| 10880 @a |
| 10881 @b |
| 10882 dynamic m() {} |
| 10883 } |
| 10884 const dynamic a = null; |
| 10885 const dynamic b = null; |
| 10886 '''); |
| 10887 } else { |
| 10888 checkElementText( |
| 10889 library, |
| 10890 r''' |
| 10891 class C { |
| 10892 @a |
| 10893 @b |
| 10894 dynamic m() {} |
| 10895 } |
| 10896 const dynamic a = null; |
| 10897 const dynamic b = null; |
| 10898 '''); |
| 10899 } |
| 4332 } | 10900 } |
| 4333 | 10901 |
| 4334 test_metadata_methodDeclaration_setter() { | 10902 test_metadata_methodDeclaration_setter() { |
| 4335 checkLibrary('const a = null; class C { @a set m(value) {} }'); | 10903 var library = |
| 10904 checkLibrary('const a = null; class C { @a set m(value) {} }'); |
| 10905 if (isStrongMode) { |
| 10906 checkElementText( |
| 10907 library, |
| 10908 r''' |
| 10909 class C { |
| 10910 @a |
| 10911 void set m(dynamic value) {} |
| 10912 } |
| 10913 const dynamic a = null; |
| 10914 '''); |
| 10915 } else { |
| 10916 checkElementText( |
| 10917 library, |
| 10918 r''' |
| 10919 class C { |
| 10920 @a |
| 10921 dynamic set m(dynamic value) {} |
| 10922 } |
| 10923 const dynamic a = null; |
| 10924 '''); |
| 10925 } |
| 4336 } | 10926 } |
| 4337 | 10927 |
| 4338 test_metadata_partDirective() { | 10928 test_metadata_partDirective() { |
| 4339 addSource('/foo.dart', 'part of L;'); | 10929 addSource('/foo.dart', 'part of L;'); |
| 4340 checkLibrary('library L; @a part "foo.dart"; const a = null;'); | 10930 var library = |
| 10931 checkLibrary('library L; @a part "foo.dart"; const a = null;'); |
| 10932 if (isStrongMode) { |
| 10933 checkElementText( |
| 10934 library, |
| 10935 r''' |
| 10936 library L; |
| 10937 @a |
| 10938 part 'foo.dart'; |
| 10939 const dynamic a = null; |
| 10940 -------------------- |
| 10941 unit: foo.dart |
| 10942 |
| 10943 '''); |
| 10944 } else { |
| 10945 checkElementText( |
| 10946 library, |
| 10947 r''' |
| 10948 library L; |
| 10949 @a |
| 10950 part 'foo.dart'; |
| 10951 const dynamic a = null; |
| 10952 -------------------- |
| 10953 unit: foo.dart |
| 10954 |
| 10955 '''); |
| 10956 } |
| 4341 } | 10957 } |
| 4342 | 10958 |
| 4343 test_metadata_prefixed_variable() { | 10959 test_metadata_prefixed_variable() { |
| 4344 addLibrarySource('/a.dart', 'const b = null;'); | 10960 addLibrarySource('/a.dart', 'const b = null;'); |
| 4345 checkLibrary('import "a.dart" as a; @a.b class C {}'); | 10961 var library = checkLibrary('import "a.dart" as a; @a.b class C {}'); |
| 10962 if (isStrongMode) { |
| 10963 checkElementText( |
| 10964 library, |
| 10965 r''' |
| 10966 import 'a.dart' as a; |
| 10967 @a.b |
| 10968 class C { |
| 10969 } |
| 10970 '''); |
| 10971 } else { |
| 10972 checkElementText( |
| 10973 library, |
| 10974 r''' |
| 10975 import 'a.dart' as a; |
| 10976 @a.b |
| 10977 class C { |
| 10978 } |
| 10979 '''); |
| 10980 } |
| 4346 } | 10981 } |
| 4347 | 10982 |
| 4348 test_metadata_simpleFormalParameter() { | 10983 test_metadata_simpleFormalParameter() { |
| 4349 checkLibrary('const a = null; f(@a x) {}'); | 10984 var library = checkLibrary('const a = null; f(@a x) {}'); |
| 10985 if (isStrongMode) { |
| 10986 checkElementText( |
| 10987 library, |
| 10988 r''' |
| 10989 const dynamic a = null; |
| 10990 dynamic f(@a dynamic x) {} |
| 10991 '''); |
| 10992 } else { |
| 10993 checkElementText( |
| 10994 library, |
| 10995 r''' |
| 10996 const dynamic a = null; |
| 10997 dynamic f(@a dynamic x) {} |
| 10998 '''); |
| 10999 } |
| 4350 } | 11000 } |
| 4351 | 11001 |
| 4352 test_metadata_simpleFormalParameter_withDefault() { | 11002 test_metadata_simpleFormalParameter_withDefault() { |
| 4353 checkLibrary('const a = null; f([@a x = null]) {}'); | 11003 var library = checkLibrary('const a = null; f([@a x = null]) {}'); |
| 11004 if (isStrongMode) { |
| 11005 checkElementText( |
| 11006 library, |
| 11007 r''' |
| 11008 const dynamic a = null; |
| 11009 dynamic f([@a dynamic x = null]) {} |
| 11010 '''); |
| 11011 } else { |
| 11012 checkElementText( |
| 11013 library, |
| 11014 r''' |
| 11015 const dynamic a = null; |
| 11016 dynamic f([@a dynamic x = null]) {} |
| 11017 '''); |
| 11018 } |
| 4354 } | 11019 } |
| 4355 | 11020 |
| 4356 test_metadata_topLevelVariableDeclaration() { | 11021 test_metadata_topLevelVariableDeclaration() { |
| 4357 checkLibrary('const a = null; @a int v;'); | 11022 var library = checkLibrary('const a = null; @a int v;'); |
| 11023 if (isStrongMode) { |
| 11024 checkElementText( |
| 11025 library, |
| 11026 r''' |
| 11027 const dynamic a = null; |
| 11028 @a |
| 11029 int v; |
| 11030 '''); |
| 11031 } else { |
| 11032 checkElementText( |
| 11033 library, |
| 11034 r''' |
| 11035 const dynamic a = null; |
| 11036 @a |
| 11037 int v; |
| 11038 '''); |
| 11039 } |
| 4358 } | 11040 } |
| 4359 | 11041 |
| 4360 test_metadata_typeParameter_ofClass() { | 11042 test_metadata_typeParameter_ofClass() { |
| 4361 checkLibrary('const a = null; class C<@a T> {}'); | 11043 var library = checkLibrary('const a = null; class C<@a T> {}'); |
| 11044 if (isStrongMode) { |
| 11045 checkElementText( |
| 11046 library, |
| 11047 r''' |
| 11048 class C<T> { |
| 11049 } |
| 11050 const dynamic a = null; |
| 11051 '''); |
| 11052 } else { |
| 11053 checkElementText( |
| 11054 library, |
| 11055 r''' |
| 11056 class C<T> { |
| 11057 } |
| 11058 const dynamic a = null; |
| 11059 '''); |
| 11060 } |
| 4362 } | 11061 } |
| 4363 | 11062 |
| 4364 test_metadata_typeParameter_ofClassTypeAlias() { | 11063 test_metadata_typeParameter_ofClassTypeAlias() { |
| 4365 checkLibrary( | 11064 var library = checkLibrary( |
| 4366 'const a = null; class C<@a T> = D with E; class D {} class E {}'); | 11065 'const a = null; class C<@a T> = D with E; class D {} class E {}'); |
| 11066 if (isStrongMode) { |
| 11067 checkElementText( |
| 11068 library, |
| 11069 r''' |
| 11070 class alias C<T> extends D with E { |
| 11071 synthetic C() = D; |
| 11072 } |
| 11073 class D { |
| 11074 } |
| 11075 class E { |
| 11076 } |
| 11077 const dynamic a = null; |
| 11078 '''); |
| 11079 } else { |
| 11080 checkElementText( |
| 11081 library, |
| 11082 r''' |
| 11083 class alias C<T> extends D with E { |
| 11084 synthetic C() = D; |
| 11085 } |
| 11086 class D { |
| 11087 } |
| 11088 class E { |
| 11089 } |
| 11090 const dynamic a = null; |
| 11091 '''); |
| 11092 } |
| 4367 } | 11093 } |
| 4368 | 11094 |
| 4369 test_metadata_typeParameter_ofFunction() { | 11095 test_metadata_typeParameter_ofFunction() { |
| 4370 checkLibrary('const a = null; f<@a T>() {}'); | 11096 var library = checkLibrary('const a = null; f<@a T>() {}'); |
| 11097 if (isStrongMode) { |
| 11098 checkElementText( |
| 11099 library, |
| 11100 r''' |
| 11101 const dynamic a = null; |
| 11102 dynamic f<T>() {} |
| 11103 '''); |
| 11104 } else { |
| 11105 checkElementText( |
| 11106 library, |
| 11107 r''' |
| 11108 const dynamic a = null; |
| 11109 dynamic f<T>() {} |
| 11110 '''); |
| 11111 } |
| 4371 } | 11112 } |
| 4372 | 11113 |
| 4373 test_metadata_typeParameter_ofTypedef() { | 11114 test_metadata_typeParameter_ofTypedef() { |
| 4374 checkLibrary('const a = null; typedef F<@a T>();'); | 11115 var library = checkLibrary('const a = null; typedef F<@a T>();'); |
| 11116 if (isStrongMode) { |
| 11117 checkElementText( |
| 11118 library, |
| 11119 r''' |
| 11120 typedef dynamic F<T>(); |
| 11121 const dynamic a = null; |
| 11122 '''); |
| 11123 } else { |
| 11124 checkElementText( |
| 11125 library, |
| 11126 r''' |
| 11127 typedef dynamic F<T>(); |
| 11128 const dynamic a = null; |
| 11129 '''); |
| 11130 } |
| 4375 } | 11131 } |
| 4376 | 11132 |
| 4377 test_method_documented() { | 11133 test_method_documented() { |
| 4378 checkLibrary(''' | 11134 var library = checkLibrary(''' |
| 4379 class C { | 11135 class C { |
| 4380 /** | 11136 /** |
| 4381 * Docs | 11137 * Docs |
| 4382 */ | 11138 */ |
| 4383 f() {} | 11139 f() {} |
| 4384 }'''); | 11140 }'''); |
| 11141 if (isStrongMode) { |
| 11142 checkElementText( |
| 11143 library, |
| 11144 r''' |
| 11145 class C { |
| 11146 /** |
| 11147 * Docs |
| 11148 */ |
| 11149 dynamic f() {} |
| 11150 } |
| 11151 '''); |
| 11152 } else { |
| 11153 checkElementText( |
| 11154 library, |
| 11155 r''' |
| 11156 class C { |
| 11157 /** |
| 11158 * Docs |
| 11159 */ |
| 11160 dynamic f() {} |
| 11161 } |
| 11162 '''); |
| 11163 } |
| 4385 } | 11164 } |
| 4386 | 11165 |
| 4387 test_method_inferred_type_nonStatic_implicit_param() { | 11166 test_method_inferred_type_nonStatic_implicit_param() { |
| 4388 checkLibrary('class C extends D { void f(value) {} }' | 11167 var library = checkLibrary('class C extends D { void f(value) {} }' |
| 4389 ' abstract class D { void f(int value); }'); | 11168 ' abstract class D { void f(int value); }'); |
| 11169 if (isStrongMode) { |
| 11170 checkElementText( |
| 11171 library, |
| 11172 r''' |
| 11173 class C extends D { |
| 11174 void f(int value) {} |
| 11175 } |
| 11176 abstract class D { |
| 11177 void f(int value); |
| 11178 } |
| 11179 '''); |
| 11180 } else { |
| 11181 checkElementText( |
| 11182 library, |
| 11183 r''' |
| 11184 class C extends D { |
| 11185 void f(dynamic value) {} |
| 11186 } |
| 11187 abstract class D { |
| 11188 void f(int value); |
| 11189 } |
| 11190 '''); |
| 11191 } |
| 4390 } | 11192 } |
| 4391 | 11193 |
| 4392 test_method_inferred_type_nonStatic_implicit_return() { | 11194 test_method_inferred_type_nonStatic_implicit_return() { |
| 4393 checkLibrary( | 11195 var library = checkLibrary( |
| 4394 'class C extends D { f() => null; } abstract class D { int f(); }'); | 11196 'class C extends D { f() => null; } abstract class D { int f(); }'); |
| 11197 if (isStrongMode) { |
| 11198 checkElementText( |
| 11199 library, |
| 11200 r''' |
| 11201 class C extends D { |
| 11202 int f() {} |
| 11203 } |
| 11204 abstract class D { |
| 11205 int f(); |
| 11206 } |
| 11207 '''); |
| 11208 } else { |
| 11209 checkElementText( |
| 11210 library, |
| 11211 r''' |
| 11212 class C extends D { |
| 11213 dynamic f() {} |
| 11214 } |
| 11215 abstract class D { |
| 11216 int f(); |
| 11217 } |
| 11218 '''); |
| 11219 } |
| 4395 } | 11220 } |
| 4396 | 11221 |
| 4397 test_method_type_parameter() { | 11222 test_method_type_parameter() { |
| 4398 prepareAnalysisContext(createOptions()); | 11223 prepareAnalysisContext(createOptions()); |
| 4399 checkLibrary('class C { T f<T, U>(U u) => null; }'); | 11224 var library = checkLibrary('class C { T f<T, U>(U u) => null; }'); |
| 11225 if (isStrongMode) { |
| 11226 checkElementText( |
| 11227 library, |
| 11228 r''' |
| 11229 class C { |
| 11230 T f<T, U>(U u) {} |
| 11231 } |
| 11232 '''); |
| 11233 } else { |
| 11234 checkElementText( |
| 11235 library, |
| 11236 r''' |
| 11237 class C { |
| 11238 T f<T, U>(U u) {} |
| 11239 } |
| 11240 '''); |
| 11241 } |
| 4400 } | 11242 } |
| 4401 | 11243 |
| 4402 test_method_type_parameter_in_generic_class() { | 11244 test_method_type_parameter_in_generic_class() { |
| 4403 prepareAnalysisContext(createOptions()); | 11245 prepareAnalysisContext(createOptions()); |
| 4404 checkLibrary('class C<T, U> { V f<V, W>(T t, U u, W w) => null; }'); | 11246 var library = |
| 11247 checkLibrary('class C<T, U> { V f<V, W>(T t, U u, W w) => null; }'); |
| 11248 if (isStrongMode) { |
| 11249 checkElementText( |
| 11250 library, |
| 11251 r''' |
| 11252 class C<T, U> { |
| 11253 V f<V, W>(T t, U u, W w) {} |
| 11254 } |
| 11255 '''); |
| 11256 } else { |
| 11257 checkElementText( |
| 11258 library, |
| 11259 r''' |
| 11260 class C<T, U> { |
| 11261 V f<V, W>(T t, U u, W w) {} |
| 11262 } |
| 11263 '''); |
| 11264 } |
| 4405 } | 11265 } |
| 4406 | 11266 |
| 4407 test_method_type_parameter_with_function_typed_parameter() { | 11267 test_method_type_parameter_with_function_typed_parameter() { |
| 4408 prepareAnalysisContext(createOptions()); | 11268 prepareAnalysisContext(createOptions()); |
| 4409 checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); | 11269 var library = checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); |
| 11270 if (isStrongMode) { |
| 11271 checkElementText( |
| 11272 library, |
| 11273 r''' |
| 11274 class C { |
| 11275 void f<T, U>((U) → T x) {} |
| 11276 } |
| 11277 '''); |
| 11278 } else { |
| 11279 checkElementText( |
| 11280 library, |
| 11281 r''' |
| 11282 class C { |
| 11283 void f<T, U>((U) → T x) {} |
| 11284 } |
| 11285 '''); |
| 11286 } |
| 4410 } | 11287 } |
| 4411 | 11288 |
| 4412 test_nameConflict_exportedAndLocal() { | 11289 test_nameConflict_exportedAndLocal() { |
| 4413 namesThatCannotBeResolved.add('V'); | 11290 namesThatCannotBeResolved.add('V'); |
| 4414 addLibrarySource('/a.dart', 'class C {}'); | 11291 addLibrarySource('/a.dart', 'class C {}'); |
| 4415 addLibrarySource( | 11292 addLibrarySource( |
| 4416 '/c.dart', | 11293 '/c.dart', |
| 4417 ''' | 11294 ''' |
| 4418 export 'a.dart'; | 11295 export 'a.dart'; |
| 4419 class C {} | 11296 class C {} |
| 4420 '''); | 11297 '''); |
| 4421 checkLibrary(''' | 11298 var library = checkLibrary(''' |
| 4422 import 'c.dart'; | 11299 import 'c.dart'; |
| 4423 C v = null; | 11300 C v = null; |
| 4424 '''); | 11301 '''); |
| 11302 if (isStrongMode) { |
| 11303 checkElementText( |
| 11304 library, |
| 11305 r''' |
| 11306 import 'c.dart'; |
| 11307 C v; |
| 11308 '''); |
| 11309 } else { |
| 11310 checkElementText( |
| 11311 library, |
| 11312 r''' |
| 11313 import 'c.dart'; |
| 11314 C v; |
| 11315 '''); |
| 11316 } |
| 4425 } | 11317 } |
| 4426 | 11318 |
| 4427 test_nameConflict_exportedAndLocal_exported() { | 11319 test_nameConflict_exportedAndLocal_exported() { |
| 4428 namesThatCannotBeResolved.add('V'); | 11320 namesThatCannotBeResolved.add('V'); |
| 4429 addLibrarySource('/a.dart', 'class C {}'); | 11321 addLibrarySource('/a.dart', 'class C {}'); |
| 4430 addLibrarySource( | 11322 addLibrarySource( |
| 4431 '/c.dart', | 11323 '/c.dart', |
| 4432 ''' | 11324 ''' |
| 4433 export 'a.dart'; | 11325 export 'a.dart'; |
| 4434 class C {} | 11326 class C {} |
| 4435 '''); | 11327 '''); |
| 4436 addLibrarySource('/d.dart', 'export "c.dart";'); | 11328 addLibrarySource('/d.dart', 'export "c.dart";'); |
| 4437 checkLibrary(''' | 11329 var library = checkLibrary(''' |
| 4438 import 'd.dart'; | 11330 import 'd.dart'; |
| 4439 C v = null; | 11331 C v = null; |
| 4440 '''); | 11332 '''); |
| 11333 if (isStrongMode) { |
| 11334 checkElementText( |
| 11335 library, |
| 11336 r''' |
| 11337 import 'd.dart'; |
| 11338 C v; |
| 11339 '''); |
| 11340 } else { |
| 11341 checkElementText( |
| 11342 library, |
| 11343 r''' |
| 11344 import 'd.dart'; |
| 11345 C v; |
| 11346 '''); |
| 11347 } |
| 4441 } | 11348 } |
| 4442 | 11349 |
| 4443 test_nameConflict_exportedAndParted() { | 11350 test_nameConflict_exportedAndParted() { |
| 4444 namesThatCannotBeResolved.add('V'); | 11351 namesThatCannotBeResolved.add('V'); |
| 4445 addLibrarySource('/a.dart', 'class C {}'); | 11352 addLibrarySource('/a.dart', 'class C {}'); |
| 4446 addLibrarySource( | 11353 addLibrarySource( |
| 4447 '/b.dart', | 11354 '/b.dart', |
| 4448 ''' | 11355 ''' |
| 4449 part of lib; | 11356 part of lib; |
| 4450 class C {} | 11357 class C {} |
| 4451 '''); | 11358 '''); |
| 4452 addLibrarySource( | 11359 addLibrarySource( |
| 4453 '/c.dart', | 11360 '/c.dart', |
| 4454 ''' | 11361 ''' |
| 4455 library lib; | 11362 library lib; |
| 4456 export 'a.dart'; | 11363 export 'a.dart'; |
| 4457 part 'b.dart'; | 11364 part 'b.dart'; |
| 4458 '''); | 11365 '''); |
| 4459 checkLibrary(''' | 11366 var library = checkLibrary(''' |
| 4460 import 'c.dart'; | 11367 import 'c.dart'; |
| 4461 C v = null; | 11368 C v = null; |
| 4462 '''); | 11369 '''); |
| 11370 if (isStrongMode) { |
| 11371 checkElementText( |
| 11372 library, |
| 11373 r''' |
| 11374 import 'c.dart'; |
| 11375 C v; |
| 11376 '''); |
| 11377 } else { |
| 11378 checkElementText( |
| 11379 library, |
| 11380 r''' |
| 11381 import 'c.dart'; |
| 11382 C v; |
| 11383 '''); |
| 11384 } |
| 4463 } | 11385 } |
| 4464 | 11386 |
| 4465 test_nameConflict_importWithRelativeUri_exportWithAbsolute() { | 11387 test_nameConflict_importWithRelativeUri_exportWithAbsolute() { |
| 4466 if (resourceProvider.pathContext.separator != '/') { | 11388 if (resourceProvider.pathContext.separator != '/') { |
| 4467 return; | 11389 return; |
| 4468 } | 11390 } |
| 4469 | 11391 |
| 4470 addLibrarySource('/a.dart', 'class A {}'); | 11392 addLibrarySource('/a.dart', 'class A {}'); |
| 4471 addLibrarySource('/b.dart', 'export "/a.dart";'); | 11393 addLibrarySource('/b.dart', 'export "/a.dart";'); |
| 4472 checkLibrary(''' | 11394 var library = checkLibrary(''' |
| 4473 import 'a.dart'; | 11395 import 'a.dart'; |
| 4474 import 'b.dart'; | 11396 import 'b.dart'; |
| 4475 A v = null; | 11397 A v = null; |
| 4476 '''); | 11398 '''); |
| 11399 if (isStrongMode) { |
| 11400 checkElementText( |
| 11401 library, |
| 11402 r''' |
| 11403 import 'a.dart'; |
| 11404 import 'b.dart'; |
| 11405 A v; |
| 11406 '''); |
| 11407 } else { |
| 11408 checkElementText( |
| 11409 library, |
| 11410 r''' |
| 11411 import 'a.dart'; |
| 11412 import 'b.dart'; |
| 11413 A v; |
| 11414 '''); |
| 11415 } |
| 4477 } | 11416 } |
| 4478 | 11417 |
| 4479 test_nested_generic_functions_in_generic_class_with_function_typed_params() { | 11418 test_nested_generic_functions_in_generic_class_with_function_typed_params() { |
| 4480 checkLibrary(''' | 11419 var library = checkLibrary(''' |
| 4481 class C<T, U> { | 11420 class C<T, U> { |
| 4482 void g<V, W>() { | 11421 void g<V, W>() { |
| 4483 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { | 11422 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { |
| 4484 } | 11423 } |
| 4485 } | 11424 } |
| 4486 } | 11425 } |
| 4487 '''); | 11426 '''); |
| 11427 if (isStrongMode) { |
| 11428 checkElementText( |
| 11429 library, |
| 11430 r''' |
| 11431 class C<T, U> { |
| 11432 void g<V, W>() {} |
| 11433 } |
| 11434 '''); |
| 11435 } else { |
| 11436 checkElementText( |
| 11437 library, |
| 11438 r''' |
| 11439 class C<T, U> { |
| 11440 void g<V, W>() {} |
| 11441 } |
| 11442 '''); |
| 11443 } |
| 4488 } | 11444 } |
| 4489 | 11445 |
| 4490 test_nested_generic_functions_in_generic_class_with_local_variables() { | 11446 test_nested_generic_functions_in_generic_class_with_local_variables() { |
| 4491 checkLibrary(''' | 11447 var library = checkLibrary(''' |
| 4492 class C<T, U> { | 11448 class C<T, U> { |
| 4493 void g<V, W>() { | 11449 void g<V, W>() { |
| 4494 void h<X, Y>() { | 11450 void h<X, Y>() { |
| 4495 T t; | 11451 T t; |
| 4496 U u; | 11452 U u; |
| 4497 V v; | 11453 V v; |
| 4498 W w; | 11454 W w; |
| 4499 X x; | 11455 X x; |
| 4500 Y y; | 11456 Y y; |
| 4501 } | 11457 } |
| 4502 } | 11458 } |
| 4503 } | 11459 } |
| 4504 '''); | 11460 '''); |
| 11461 if (isStrongMode) { |
| 11462 checkElementText( |
| 11463 library, |
| 11464 r''' |
| 11465 class C<T, U> { |
| 11466 void g<V, W>() {} |
| 11467 } |
| 11468 '''); |
| 11469 } else { |
| 11470 checkElementText( |
| 11471 library, |
| 11472 r''' |
| 11473 class C<T, U> { |
| 11474 void g<V, W>() {} |
| 11475 } |
| 11476 '''); |
| 11477 } |
| 4505 } | 11478 } |
| 4506 | 11479 |
| 4507 test_nested_generic_functions_with_function_typed_param() { | 11480 test_nested_generic_functions_with_function_typed_param() { |
| 4508 checkLibrary(''' | 11481 var library = checkLibrary(''' |
| 4509 void f<T, U>() { | 11482 void f<T, U>() { |
| 4510 void g<V, W>() { | 11483 void g<V, W>() { |
| 4511 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { | 11484 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { |
| 4512 } | 11485 } |
| 4513 } | 11486 } |
| 4514 } | 11487 } |
| 4515 '''); | 11488 '''); |
| 11489 if (isStrongMode) { |
| 11490 checkElementText( |
| 11491 library, |
| 11492 r''' |
| 11493 void f<T, U>() {} |
| 11494 '''); |
| 11495 } else { |
| 11496 checkElementText( |
| 11497 library, |
| 11498 r''' |
| 11499 void f<T, U>() {} |
| 11500 '''); |
| 11501 } |
| 4516 } | 11502 } |
| 4517 | 11503 |
| 4518 test_nested_generic_functions_with_local_variables() { | 11504 test_nested_generic_functions_with_local_variables() { |
| 4519 checkLibrary(''' | 11505 var library = checkLibrary(''' |
| 4520 void f<T, U>() { | 11506 void f<T, U>() { |
| 4521 void g<V, W>() { | 11507 void g<V, W>() { |
| 4522 void h<X, Y>() { | 11508 void h<X, Y>() { |
| 4523 T t; | 11509 T t; |
| 4524 U u; | 11510 U u; |
| 4525 V v; | 11511 V v; |
| 4526 W w; | 11512 W w; |
| 4527 X x; | 11513 X x; |
| 4528 Y y; | 11514 Y y; |
| 4529 } | 11515 } |
| 4530 } | 11516 } |
| 4531 } | 11517 } |
| 4532 '''); | 11518 '''); |
| 11519 if (isStrongMode) { |
| 11520 checkElementText( |
| 11521 library, |
| 11522 r''' |
| 11523 void f<T, U>() {} |
| 11524 '''); |
| 11525 } else { |
| 11526 checkElementText( |
| 11527 library, |
| 11528 r''' |
| 11529 void f<T, U>() {} |
| 11530 '''); |
| 11531 } |
| 4533 } | 11532 } |
| 4534 | 11533 |
| 4535 test_operator() { | 11534 test_operator() { |
| 4536 checkLibrary('class C { C operator+(C other) => null; }'); | 11535 var library = checkLibrary('class C { C operator+(C other) => null; }'); |
| 11536 if (isStrongMode) { |
| 11537 checkElementText( |
| 11538 library, |
| 11539 r''' |
| 11540 class C { |
| 11541 C +(C other) {} |
| 11542 } |
| 11543 '''); |
| 11544 } else { |
| 11545 checkElementText( |
| 11546 library, |
| 11547 r''' |
| 11548 class C { |
| 11549 C +(C other) {} |
| 11550 } |
| 11551 '''); |
| 11552 } |
| 4537 } | 11553 } |
| 4538 | 11554 |
| 4539 test_operator_equal() { | 11555 test_operator_equal() { |
| 4540 checkLibrary('class C { bool operator==(Object other) => false; }'); | 11556 var library = |
| 11557 checkLibrary('class C { bool operator==(Object other) => false; }'); |
| 11558 if (isStrongMode) { |
| 11559 checkElementText( |
| 11560 library, |
| 11561 r''' |
| 11562 class C { |
| 11563 bool ==(Object other) {} |
| 11564 } |
| 11565 '''); |
| 11566 } else { |
| 11567 checkElementText( |
| 11568 library, |
| 11569 r''' |
| 11570 class C { |
| 11571 bool ==(Object other) {} |
| 11572 } |
| 11573 '''); |
| 11574 } |
| 4541 } | 11575 } |
| 4542 | 11576 |
| 4543 test_operator_external() { | 11577 test_operator_external() { |
| 4544 checkLibrary('class C { external C operator+(C other); }'); | 11578 var library = checkLibrary('class C { external C operator+(C other); }'); |
| 11579 if (isStrongMode) { |
| 11580 checkElementText( |
| 11581 library, |
| 11582 r''' |
| 11583 class C { |
| 11584 external C +(C other) {} |
| 11585 } |
| 11586 '''); |
| 11587 } else { |
| 11588 checkElementText( |
| 11589 library, |
| 11590 r''' |
| 11591 class C { |
| 11592 external C +(C other) {} |
| 11593 } |
| 11594 '''); |
| 11595 } |
| 4545 } | 11596 } |
| 4546 | 11597 |
| 4547 test_operator_greater_equal() { | 11598 test_operator_greater_equal() { |
| 4548 checkLibrary('class C { bool operator>=(C other) => false; }'); | 11599 var library = |
| 11600 checkLibrary('class C { bool operator>=(C other) => false; }'); |
| 11601 if (isStrongMode) { |
| 11602 checkElementText( |
| 11603 library, |
| 11604 r''' |
| 11605 class C { |
| 11606 bool >=(C other) {} |
| 11607 } |
| 11608 '''); |
| 11609 } else { |
| 11610 checkElementText( |
| 11611 library, |
| 11612 r''' |
| 11613 class C { |
| 11614 bool >=(C other) {} |
| 11615 } |
| 11616 '''); |
| 11617 } |
| 4549 } | 11618 } |
| 4550 | 11619 |
| 4551 test_operator_index() { | 11620 test_operator_index() { |
| 4552 checkLibrary('class C { bool operator[](int i) => null; }'); | 11621 var library = checkLibrary('class C { bool operator[](int i) => null; }'); |
| 11622 if (isStrongMode) { |
| 11623 checkElementText( |
| 11624 library, |
| 11625 r''' |
| 11626 class C { |
| 11627 bool [](int i) {} |
| 11628 } |
| 11629 '''); |
| 11630 } else { |
| 11631 checkElementText( |
| 11632 library, |
| 11633 r''' |
| 11634 class C { |
| 11635 bool [](int i) {} |
| 11636 } |
| 11637 '''); |
| 11638 } |
| 4553 } | 11639 } |
| 4554 | 11640 |
| 4555 test_operator_index_set() { | 11641 test_operator_index_set() { |
| 4556 checkLibrary('class C { void operator[]=(int i, bool v) {} }'); | 11642 var library = |
| 11643 checkLibrary('class C { void operator[]=(int i, bool v) {} }'); |
| 11644 if (isStrongMode) { |
| 11645 checkElementText( |
| 11646 library, |
| 11647 r''' |
| 11648 class C { |
| 11649 void []=(int i, bool v) {} |
| 11650 } |
| 11651 '''); |
| 11652 } else { |
| 11653 checkElementText( |
| 11654 library, |
| 11655 r''' |
| 11656 class C { |
| 11657 void []=(int i, bool v) {} |
| 11658 } |
| 11659 '''); |
| 11660 } |
| 4557 } | 11661 } |
| 4558 | 11662 |
| 4559 test_operator_less_equal() { | 11663 test_operator_less_equal() { |
| 4560 checkLibrary('class C { bool operator<=(C other) => false; }'); | 11664 var library = |
| 11665 checkLibrary('class C { bool operator<=(C other) => false; }'); |
| 11666 if (isStrongMode) { |
| 11667 checkElementText( |
| 11668 library, |
| 11669 r''' |
| 11670 class C { |
| 11671 bool <=(C other) {} |
| 11672 } |
| 11673 '''); |
| 11674 } else { |
| 11675 checkElementText( |
| 11676 library, |
| 11677 r''' |
| 11678 class C { |
| 11679 bool <=(C other) {} |
| 11680 } |
| 11681 '''); |
| 11682 } |
| 4561 } | 11683 } |
| 4562 | 11684 |
| 4563 void test_parameter_checked() { | 11685 void test_parameter_checked() { |
| 4564 // Note: due to dartbug.com/27393, the keyword "checked" is identified by | 11686 // Note: due to dartbug.com/27393, the keyword "checked" is identified by |
| 4565 // its presence in a library called "meta". If that bug is fixed, this test | 11687 // its presence in a library called "meta". If that bug is fixed, this test |
| 4566 // my need to be changed. | 11688 // my need to be changed. |
| 4567 checkLibrary(r''' | 11689 var library = checkLibrary(r''' |
| 4568 library meta; | 11690 library meta; |
| 4569 const checked = null; | 11691 const checked = null; |
| 4570 class A<T> { | 11692 class A<T> { |
| 4571 void f(@checked T t) {} | 11693 void f(@checked T t) {} |
| 4572 } | 11694 } |
| 4573 '''); | 11695 '''); |
| 11696 if (isStrongMode) { |
| 11697 checkElementText( |
| 11698 library, |
| 11699 r''' |
| 11700 library meta; |
| 11701 class A<T> { |
| 11702 void f(@checked covariant T t) {} |
| 11703 } |
| 11704 const dynamic checked = null; |
| 11705 '''); |
| 11706 } else { |
| 11707 checkElementText( |
| 11708 library, |
| 11709 r''' |
| 11710 library meta; |
| 11711 class A<T> { |
| 11712 void f(@checked covariant T t) {} |
| 11713 } |
| 11714 const dynamic checked = null; |
| 11715 '''); |
| 11716 } |
| 4574 } | 11717 } |
| 4575 | 11718 |
| 4576 void test_parameter_checked_inherited() { | 11719 void test_parameter_checked_inherited() { |
| 4577 // Note: due to dartbug.com/27393, the keyword "checked" is identified by | 11720 // Note: due to dartbug.com/27393, the keyword "checked" is identified by |
| 4578 // its presence in a library called "meta". If that bug is fixed, this test | 11721 // its presence in a library called "meta". If that bug is fixed, this test |
| 4579 // my need to be changed. | 11722 // my need to be changed. |
| 4580 checkLibrary(r''' | 11723 var library = checkLibrary(r''' |
| 4581 library meta; | 11724 library meta; |
| 4582 const checked = null; | 11725 const checked = null; |
| 4583 class A<T> { | 11726 class A<T> { |
| 4584 void f(@checked T t) {} | 11727 void f(@checked T t) {} |
| 4585 } | 11728 } |
| 4586 class B<T> extends A<T> { | 11729 class B<T> extends A<T> { |
| 4587 void f(T t) {} | 11730 void f(T t) {} |
| 4588 } | 11731 } |
| 4589 '''); | 11732 '''); |
| 11733 if (isStrongMode) { |
| 11734 checkElementText( |
| 11735 library, |
| 11736 r''' |
| 11737 library meta; |
| 11738 class A<T> { |
| 11739 void f(@checked covariant T t) {} |
| 11740 } |
| 11741 class B<T> extends A<T> { |
| 11742 void f(covariant T t) {} |
| 11743 } |
| 11744 const dynamic checked = null; |
| 11745 '''); |
| 11746 } else { |
| 11747 checkElementText( |
| 11748 library, |
| 11749 r''' |
| 11750 library meta; |
| 11751 class A<T> { |
| 11752 void f(@checked covariant T t) {} |
| 11753 } |
| 11754 class B<T> extends A<T> { |
| 11755 void f(T t) {} |
| 11756 } |
| 11757 const dynamic checked = null; |
| 11758 '''); |
| 11759 } |
| 4590 } | 11760 } |
| 4591 | 11761 |
| 4592 test_parameter_covariant() { | 11762 test_parameter_covariant() { |
| 4593 prepareAnalysisContext(createOptions()); | 11763 prepareAnalysisContext(createOptions()); |
| 4594 checkLibrary('class C { void m(covariant C c) {} }'); | 11764 var library = checkLibrary('class C { void m(covariant C c) {} }'); |
| 11765 if (isStrongMode) { |
| 11766 checkElementText( |
| 11767 library, |
| 11768 r''' |
| 11769 class C { |
| 11770 void m(covariant C c) {} |
| 11771 } |
| 11772 '''); |
| 11773 } else { |
| 11774 checkElementText( |
| 11775 library, |
| 11776 r''' |
| 11777 class C { |
| 11778 void m(covariant C c) {} |
| 11779 } |
| 11780 '''); |
| 11781 } |
| 4595 } | 11782 } |
| 4596 | 11783 |
| 4597 void test_parameter_covariant_inherited() { | 11784 void test_parameter_covariant_inherited() { |
| 4598 checkLibrary(r''' | 11785 var library = checkLibrary(r''' |
| 4599 class A<T> { | 11786 class A<T> { |
| 4600 void f(covariant T t) {} | 11787 void f(covariant T t) {} |
| 4601 } | 11788 } |
| 11789 class B<T> extends A<T> { |
| 11790 void f(T t) {} |
| 11791 } |
| 11792 '''); |
| 11793 if (isStrongMode) { |
| 11794 checkElementText( |
| 11795 library, |
| 11796 r''' |
| 11797 class A<T> { |
| 11798 void f(covariant T t) {} |
| 11799 } |
| 11800 class B<T> extends A<T> { |
| 11801 void f(covariant T t) {} |
| 11802 } |
| 11803 '''); |
| 11804 } else { |
| 11805 checkElementText( |
| 11806 library, |
| 11807 r''' |
| 11808 class A<T> { |
| 11809 void f(covariant T t) {} |
| 11810 } |
| 4602 class B<T> extends A<T> { | 11811 class B<T> extends A<T> { |
| 4603 void f(T t) {} | 11812 void f(T t) {} |
| 4604 } | 11813 } |
| 4605 '''); | 11814 '''); |
| 11815 } |
| 4606 } | 11816 } |
| 4607 | 11817 |
| 4608 test_parameter_parameters() { | 11818 test_parameter_parameters() { |
| 4609 checkLibrary('class C { f(g(x, y)) {} }'); | 11819 var library = checkLibrary('class C { f(g(x, y)) {} }'); |
| 11820 if (isStrongMode) { |
| 11821 checkElementText( |
| 11822 library, |
| 11823 r''' |
| 11824 class C { |
| 11825 dynamic f((dynamic, dynamic) → dynamic g) {} |
| 11826 } |
| 11827 '''); |
| 11828 } else { |
| 11829 checkElementText( |
| 11830 library, |
| 11831 r''' |
| 11832 class C { |
| 11833 dynamic f((dynamic, dynamic) → dynamic g) {} |
| 11834 } |
| 11835 '''); |
| 11836 } |
| 4610 } | 11837 } |
| 4611 | 11838 |
| 4612 test_parameter_parameters_in_generic_class() { | 11839 test_parameter_parameters_in_generic_class() { |
| 4613 checkLibrary('class C<A, B> { f(A g(B x)) {} }'); | 11840 var library = checkLibrary('class C<A, B> { f(A g(B x)) {} }'); |
| 11841 if (isStrongMode) { |
| 11842 checkElementText( |
| 11843 library, |
| 11844 r''' |
| 11845 class C<A, B> { |
| 11846 dynamic f((B) → A g) {} |
| 11847 } |
| 11848 '''); |
| 11849 } else { |
| 11850 checkElementText( |
| 11851 library, |
| 11852 r''' |
| 11853 class C<A, B> { |
| 11854 dynamic f((B) → A g) {} |
| 11855 } |
| 11856 '''); |
| 11857 } |
| 4614 } | 11858 } |
| 4615 | 11859 |
| 4616 test_parameter_return_type() { | 11860 test_parameter_return_type() { |
| 4617 checkLibrary('class C { f(int g()) {} }'); | 11861 var library = checkLibrary('class C { f(int g()) {} }'); |
| 11862 if (isStrongMode) { |
| 11863 checkElementText( |
| 11864 library, |
| 11865 r''' |
| 11866 class C { |
| 11867 dynamic f(() → int g) {} |
| 11868 } |
| 11869 '''); |
| 11870 } else { |
| 11871 checkElementText( |
| 11872 library, |
| 11873 r''' |
| 11874 class C { |
| 11875 dynamic f(() → int g) {} |
| 11876 } |
| 11877 '''); |
| 11878 } |
| 4618 } | 11879 } |
| 4619 | 11880 |
| 4620 test_parameter_return_type_void() { | 11881 test_parameter_return_type_void() { |
| 4621 checkLibrary('class C { f(void g()) {} }'); | 11882 var library = checkLibrary('class C { f(void g()) {} }'); |
| 11883 if (isStrongMode) { |
| 11884 checkElementText( |
| 11885 library, |
| 11886 r''' |
| 11887 class C { |
| 11888 dynamic f(() → void g) {} |
| 11889 } |
| 11890 '''); |
| 11891 } else { |
| 11892 checkElementText( |
| 11893 library, |
| 11894 r''' |
| 11895 class C { |
| 11896 dynamic f(() → void g) {} |
| 11897 } |
| 11898 '''); |
| 11899 } |
| 4622 } | 11900 } |
| 4623 | 11901 |
| 4624 test_parameterTypeNotInferred_constructor() { | 11902 test_parameterTypeNotInferred_constructor() { |
| 4625 // Strong mode doesn't do type inference on constructor parameters, so it's | 11903 // Strong mode doesn't do type inference on constructor parameters, so it's |
| 4626 // ok that we don't store inferred type info for them in summaries. | 11904 // ok that we don't store inferred type info for them in summaries. |
| 4627 checkLibrary(''' | 11905 var library = checkLibrary(''' |
| 4628 class C { | 11906 class C { |
| 4629 C.positional([x = 1]); | 11907 C.positional([x = 1]); |
| 4630 C.named({x: 1}); | 11908 C.named({x: 1}); |
| 4631 } | 11909 } |
| 4632 '''); | 11910 '''); |
| 11911 if (isStrongMode) { |
| 11912 checkElementText( |
| 11913 library, |
| 11914 r''' |
| 11915 class C { |
| 11916 C.positional([dynamic x = 1]); |
| 11917 C.named({dynamic x: 1}); |
| 11918 } |
| 11919 '''); |
| 11920 } else { |
| 11921 checkElementText( |
| 11922 library, |
| 11923 r''' |
| 11924 class C { |
| 11925 C.positional([dynamic x = 1]); |
| 11926 C.named({dynamic x: 1}); |
| 11927 } |
| 11928 '''); |
| 11929 } |
| 4633 } | 11930 } |
| 4634 | 11931 |
| 4635 test_parameterTypeNotInferred_initializingFormal() { | 11932 test_parameterTypeNotInferred_initializingFormal() { |
| 4636 // Strong mode doesn't do type inference on initializing formals, so it's | 11933 // Strong mode doesn't do type inference on initializing formals, so it's |
| 4637 // ok that we don't store inferred type info for them in summaries. | 11934 // ok that we don't store inferred type info for them in summaries. |
| 4638 checkLibrary(''' | 11935 var library = checkLibrary(''' |
| 4639 class C { | 11936 class C { |
| 4640 var x; | 11937 var x; |
| 4641 C.positional([this.x = 1]); | 11938 C.positional([this.x = 1]); |
| 4642 C.named({this.x: 1}); | 11939 C.named({this.x: 1}); |
| 4643 } | 11940 } |
| 4644 '''); | 11941 '''); |
| 11942 if (isStrongMode) { |
| 11943 checkElementText( |
| 11944 library, |
| 11945 r''' |
| 11946 class C { |
| 11947 dynamic x; |
| 11948 C.positional([dynamic this.x]); |
| 11949 C.named({dynamic this.x}); |
| 11950 } |
| 11951 '''); |
| 11952 } else { |
| 11953 checkElementText( |
| 11954 library, |
| 11955 r''' |
| 11956 class C { |
| 11957 dynamic x; |
| 11958 C.positional([dynamic this.x]); |
| 11959 C.named({dynamic this.x}); |
| 11960 } |
| 11961 '''); |
| 11962 } |
| 4645 } | 11963 } |
| 4646 | 11964 |
| 4647 test_parameterTypeNotInferred_staticMethod() { | 11965 test_parameterTypeNotInferred_staticMethod() { |
| 4648 // Strong mode doesn't do type inference on parameters of static methods, | 11966 // Strong mode doesn't do type inference on parameters of static methods, |
| 4649 // so it's ok that we don't store inferred type info for them in summaries. | 11967 // so it's ok that we don't store inferred type info for them in summaries. |
| 4650 checkLibrary(''' | 11968 var library = checkLibrary(''' |
| 4651 class C { | 11969 class C { |
| 4652 static void positional([x = 1]) {} | 11970 static void positional([x = 1]) {} |
| 4653 static void named({x: 1}) {} | 11971 static void named({x: 1}) {} |
| 4654 } | 11972 } |
| 4655 '''); | 11973 '''); |
| 11974 if (isStrongMode) { |
| 11975 checkElementText( |
| 11976 library, |
| 11977 r''' |
| 11978 class C { |
| 11979 static void positional([dynamic x = 1]) {} |
| 11980 static void named({dynamic x: 1}) {} |
| 11981 } |
| 11982 '''); |
| 11983 } else { |
| 11984 checkElementText( |
| 11985 library, |
| 11986 r''' |
| 11987 class C { |
| 11988 static void positional([dynamic x = 1]) {} |
| 11989 static void named({dynamic x: 1}) {} |
| 11990 } |
| 11991 '''); |
| 11992 } |
| 4656 } | 11993 } |
| 4657 | 11994 |
| 4658 test_parameterTypeNotInferred_topLevelFunction() { | 11995 test_parameterTypeNotInferred_topLevelFunction() { |
| 4659 // Strong mode doesn't do type inference on parameters of top level | 11996 // Strong mode doesn't do type inference on parameters of top level |
| 4660 // functions, so it's ok that we don't store inferred type info for them in | 11997 // functions, so it's ok that we don't store inferred type info for them in |
| 4661 // summaries. | 11998 // summaries. |
| 4662 checkLibrary(''' | 11999 var library = checkLibrary(''' |
| 4663 void positional([x = 1]) {} | 12000 void positional([x = 1]) {} |
| 4664 void named({x: 1}) {} | 12001 void named({x: 1}) {} |
| 4665 '''); | 12002 '''); |
| 12003 if (isStrongMode) { |
| 12004 checkElementText( |
| 12005 library, |
| 12006 r''' |
| 12007 void positional([dynamic x = 1]) {} |
| 12008 void named({dynamic x: 1}) {} |
| 12009 '''); |
| 12010 } else { |
| 12011 checkElementText( |
| 12012 library, |
| 12013 r''' |
| 12014 void positional([dynamic x = 1]) {} |
| 12015 void named({dynamic x: 1}) {} |
| 12016 '''); |
| 12017 } |
| 4666 } | 12018 } |
| 4667 | 12019 |
| 4668 test_parts() { | 12020 test_parts() { |
| 4669 addSource('/a.dart', 'part of my.lib;'); | 12021 addSource('/a.dart', 'part of my.lib;'); |
| 4670 addSource('/b.dart', 'part of my.lib;'); | 12022 addSource('/b.dart', 'part of my.lib;'); |
| 4671 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 12023 var library = checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 12024 if (isStrongMode) { |
| 12025 checkElementText( |
| 12026 library, |
| 12027 r''' |
| 12028 library my.lib; |
| 12029 part 'a.dart'; |
| 12030 part 'b.dart'; |
| 12031 -------------------- |
| 12032 unit: a.dart |
| 12033 |
| 12034 -------------------- |
| 12035 unit: b.dart |
| 12036 |
| 12037 '''); |
| 12038 } else { |
| 12039 checkElementText( |
| 12040 library, |
| 12041 r''' |
| 12042 library my.lib; |
| 12043 part 'a.dart'; |
| 12044 part 'b.dart'; |
| 12045 -------------------- |
| 12046 unit: a.dart |
| 12047 |
| 12048 -------------------- |
| 12049 unit: b.dart |
| 12050 |
| 12051 '''); |
| 12052 } |
| 4672 } | 12053 } |
| 4673 | 12054 |
| 4674 test_parts_invalidUri() { | 12055 test_parts_invalidUri() { |
| 4675 allowMissingFiles = true; | 12056 allowMissingFiles = true; |
| 4676 addSource('/foo/bar.dart', 'part of my.lib;'); | 12057 addSource('/foo/bar.dart', 'part of my.lib;'); |
| 4677 checkLibrary('library my.lib; part "foo/";'); | 12058 var library = checkLibrary('library my.lib; part "foo/";'); |
| 12059 if (isStrongMode) { |
| 12060 checkElementText( |
| 12061 library, |
| 12062 r''' |
| 12063 library my.lib; |
| 12064 '''); |
| 12065 } else { |
| 12066 checkElementText( |
| 12067 library, |
| 12068 r''' |
| 12069 library my.lib; |
| 12070 '''); |
| 12071 } |
| 4678 } | 12072 } |
| 4679 | 12073 |
| 4680 test_parts_invalidUri_nullStringValue() { | 12074 test_parts_invalidUri_nullStringValue() { |
| 4681 allowMissingFiles = true; | 12075 allowMissingFiles = true; |
| 4682 addSource('/foo/bar.dart', 'part of my.lib;'); | 12076 addSource('/foo/bar.dart', 'part of my.lib;'); |
| 4683 checkLibrary(r''' | 12077 var library = checkLibrary(r''' |
| 4684 library my.lib; | 12078 library my.lib; |
| 4685 part "${foo}/bar.dart"; | 12079 part "${foo}/bar.dart"; |
| 4686 '''); | 12080 '''); |
| 12081 if (isStrongMode) { |
| 12082 checkElementText( |
| 12083 library, |
| 12084 r''' |
| 12085 library my.lib; |
| 12086 '''); |
| 12087 } else { |
| 12088 checkElementText( |
| 12089 library, |
| 12090 r''' |
| 12091 library my.lib; |
| 12092 '''); |
| 12093 } |
| 4687 } | 12094 } |
| 4688 | 12095 |
| 4689 test_propagated_type_refers_to_closure() { | 12096 test_propagated_type_refers_to_closure() { |
| 4690 checkLibrary(''' | 12097 var library = checkLibrary(''' |
| 4691 void f() { | 12098 void f() { |
| 4692 var x = () => 0; | 12099 var x = () => 0; |
| 4693 var y = x; | 12100 var y = x; |
| 4694 } | 12101 } |
| 4695 '''); | 12102 '''); |
| 12103 if (isStrongMode) { |
| 12104 checkElementText( |
| 12105 library, |
| 12106 r''' |
| 12107 void f() {} |
| 12108 '''); |
| 12109 } else { |
| 12110 checkElementText( |
| 12111 library, |
| 12112 r''' |
| 12113 void f() {} |
| 12114 '''); |
| 12115 } |
| 4696 } | 12116 } |
| 4697 | 12117 |
| 4698 test_setter_covariant() { | 12118 test_setter_covariant() { |
| 4699 checkLibrary('class C { void set x(covariant int value); }'); | 12119 var library = checkLibrary('class C { void set x(covariant int value); }'); |
| 12120 if (isStrongMode) { |
| 12121 checkElementText( |
| 12122 library, |
| 12123 r''' |
| 12124 class C { |
| 12125 void set x(covariant int value); |
| 12126 } |
| 12127 '''); |
| 12128 } else { |
| 12129 checkElementText( |
| 12130 library, |
| 12131 r''' |
| 12132 class C { |
| 12133 void set x(covariant int value); |
| 12134 } |
| 12135 '''); |
| 12136 } |
| 4700 } | 12137 } |
| 4701 | 12138 |
| 4702 test_setter_documented() { | 12139 test_setter_documented() { |
| 4703 checkLibrary(''' | 12140 var library = checkLibrary(''' |
| 4704 // Extra comment so doc comment offset != 0 | 12141 // Extra comment so doc comment offset != 0 |
| 4705 /** | 12142 /** |
| 4706 * Docs | 12143 * Docs |
| 4707 */ | 12144 */ |
| 4708 void set x(value) {}'''); | 12145 void set x(value) {}'''); |
| 12146 if (isStrongMode) { |
| 12147 checkElementText( |
| 12148 library, |
| 12149 r''' |
| 12150 /** |
| 12151 * Docs |
| 12152 */ |
| 12153 void set x(dynamic value) {} |
| 12154 '''); |
| 12155 } else { |
| 12156 checkElementText( |
| 12157 library, |
| 12158 r''' |
| 12159 /** |
| 12160 * Docs |
| 12161 */ |
| 12162 void set x(dynamic value) {} |
| 12163 '''); |
| 12164 } |
| 4709 } | 12165 } |
| 4710 | 12166 |
| 4711 test_setter_external() { | 12167 test_setter_external() { |
| 4712 checkLibrary('external void set x(int value);'); | 12168 var library = checkLibrary('external void set x(int value);'); |
| 12169 if (isStrongMode) { |
| 12170 checkElementText( |
| 12171 library, |
| 12172 r''' |
| 12173 external void set x(int value) {} |
| 12174 '''); |
| 12175 } else { |
| 12176 checkElementText( |
| 12177 library, |
| 12178 r''' |
| 12179 external void set x(int value) {} |
| 12180 '''); |
| 12181 } |
| 4713 } | 12182 } |
| 4714 | 12183 |
| 4715 test_setter_inferred_type_nonStatic_implicit_param() { | 12184 test_setter_inferred_type_nonStatic_implicit_param() { |
| 4716 checkLibrary('class C extends D { void set f(value) {} }' | 12185 var library = checkLibrary('class C extends D { void set f(value) {} }' |
| 4717 ' abstract class D { void set f(int value); }'); | 12186 ' abstract class D { void set f(int value); }'); |
| 12187 if (isStrongMode) { |
| 12188 checkElementText( |
| 12189 library, |
| 12190 r''' |
| 12191 class C extends D { |
| 12192 void set f(int value) {} |
| 12193 } |
| 12194 abstract class D { |
| 12195 void set f(int value); |
| 12196 } |
| 12197 '''); |
| 12198 } else { |
| 12199 checkElementText( |
| 12200 library, |
| 12201 r''' |
| 12202 class C extends D { |
| 12203 void set f(dynamic value) {} |
| 12204 } |
| 12205 abstract class D { |
| 12206 void set f(int value); |
| 12207 } |
| 12208 '''); |
| 12209 } |
| 4718 } | 12210 } |
| 4719 | 12211 |
| 4720 test_setter_inferred_type_static_implicit_return() { | 12212 test_setter_inferred_type_static_implicit_return() { |
| 4721 checkLibrary('class C { static set f(int value) {} }'); | 12213 var library = checkLibrary('class C { static set f(int value) {} }'); |
| 12214 if (isStrongMode) { |
| 12215 checkElementText( |
| 12216 library, |
| 12217 r''' |
| 12218 class C { |
| 12219 static void set f(int value) {} |
| 12220 } |
| 12221 '''); |
| 12222 } else { |
| 12223 checkElementText( |
| 12224 library, |
| 12225 r''' |
| 12226 class C { |
| 12227 static dynamic set f(int value) {} |
| 12228 } |
| 12229 '''); |
| 12230 } |
| 4722 } | 12231 } |
| 4723 | 12232 |
| 4724 test_setter_inferred_type_top_level_implicit_return() { | 12233 test_setter_inferred_type_top_level_implicit_return() { |
| 4725 checkLibrary('set f(int value) {}'); | 12234 var library = checkLibrary('set f(int value) {}'); |
| 12235 if (isStrongMode) { |
| 12236 checkElementText( |
| 12237 library, |
| 12238 r''' |
| 12239 void set f(int value) {} |
| 12240 '''); |
| 12241 } else { |
| 12242 checkElementText( |
| 12243 library, |
| 12244 r''' |
| 12245 dynamic set f(int value) {} |
| 12246 '''); |
| 12247 } |
| 4726 } | 12248 } |
| 4727 | 12249 |
| 4728 test_setters() { | 12250 test_setters() { |
| 4729 checkLibrary('void set x(int value) {} set y(value) {}'); | 12251 var library = checkLibrary('void set x(int value) {} set y(value) {}'); |
| 12252 if (isStrongMode) { |
| 12253 checkElementText( |
| 12254 library, |
| 12255 r''' |
| 12256 void set x(int value) {} |
| 12257 void set y(dynamic value) {} |
| 12258 '''); |
| 12259 } else { |
| 12260 checkElementText( |
| 12261 library, |
| 12262 r''' |
| 12263 void set x(int value) {} |
| 12264 dynamic set y(dynamic value) {} |
| 12265 '''); |
| 12266 } |
| 4730 } | 12267 } |
| 4731 | 12268 |
| 4732 test_syntheticFunctionType_genericClosure() { | 12269 test_syntheticFunctionType_genericClosure() { |
| 4733 if (!createOptions().strongMode) { | 12270 if (!createOptions().strongMode) { |
| 4734 // The test below uses generic comment syntax because proper generic | 12271 // The test below uses generic comment syntax because proper generic |
| 4735 // method syntax doesn't support generic closures. So it can only run in | 12272 // method syntax doesn't support generic closures. So it can only run in |
| 4736 // strong mode. | 12273 // strong mode. |
| 4737 // TODO(paulberry): once proper generic method syntax supports generic | 12274 // TODO(paulberry): once proper generic method syntax supports generic |
| 4738 // closures, rewrite the test below without using generic comment syntax, | 12275 // closures, rewrite the test below without using generic comment syntax, |
| 4739 // and remove this hack. See dartbug.com/25819 | 12276 // and remove this hack. See dartbug.com/25819 |
| 4740 return; | 12277 return; |
| 4741 } | 12278 } |
| 4742 checkLibrary(''' | 12279 var library = checkLibrary(''' |
| 4743 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; | 12280 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; |
| 4744 bool f() => true; | 12281 bool f() => true; |
| 4745 '''); | 12282 '''); |
| 12283 if (isStrongMode) { |
| 12284 checkElementText( |
| 12285 library, |
| 12286 r''' |
| 12287 '''); |
| 12288 } else { |
| 12289 checkElementText( |
| 12290 library, |
| 12291 r''' |
| 12292 '''); |
| 12293 } |
| 4746 } | 12294 } |
| 4747 | 12295 |
| 4748 test_syntheticFunctionType_genericClosure_inGenericFunction() { | 12296 test_syntheticFunctionType_genericClosure_inGenericFunction() { |
| 4749 if (!createOptions().strongMode) { | 12297 if (!createOptions().strongMode) { |
| 4750 // The test below uses generic comment syntax because proper generic | 12298 // The test below uses generic comment syntax because proper generic |
| 4751 // method syntax doesn't support generic closures. So it can only run in | 12299 // method syntax doesn't support generic closures. So it can only run in |
| 4752 // strong mode. | 12300 // strong mode. |
| 4753 // TODO(paulberry): once proper generic method syntax supports generic | 12301 // TODO(paulberry): once proper generic method syntax supports generic |
| 4754 // closures, rewrite the test below without using generic comment syntax, | 12302 // closures, rewrite the test below without using generic comment syntax, |
| 4755 // and remove this hack. See dartbug.com/25819 | 12303 // and remove this hack. See dartbug.com/25819 |
| 4756 return; | 12304 return; |
| 4757 } | 12305 } |
| 4758 checkLibrary(''' | 12306 var library = checkLibrary(''' |
| 4759 void f<T, U>(bool b) { | 12307 void f<T, U>(bool b) { |
| 4760 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; | 12308 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; |
| 4761 } | 12309 } |
| 4762 '''); | 12310 '''); |
| 12311 if (isStrongMode) { |
| 12312 checkElementText( |
| 12313 library, |
| 12314 r''' |
| 12315 void f<T, U>(bool b) {} |
| 12316 '''); |
| 12317 } else { |
| 12318 checkElementText( |
| 12319 library, |
| 12320 r''' |
| 12321 '''); |
| 12322 } |
| 4763 } | 12323 } |
| 4764 | 12324 |
| 4765 test_syntheticFunctionType_inGenericClass() { | 12325 test_syntheticFunctionType_inGenericClass() { |
| 4766 checkLibrary(''' | 12326 var library = checkLibrary(''' |
| 4767 class C<T, U> { | 12327 class C<T, U> { |
| 4768 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; | 12328 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; |
| 4769 } | 12329 } |
| 4770 bool f() => false; | 12330 bool f() => false; |
| 4771 '''); | 12331 '''); |
| 12332 if (isStrongMode) { |
| 12333 checkElementText( |
| 12334 library, |
| 12335 r''' |
| 12336 class C { |
| 12337 synthetic C(); |
| 12338 } |
| 12339 '''); |
| 12340 } else { |
| 12341 checkElementText( |
| 12342 library, |
| 12343 r''' |
| 12344 class C<T, U> { |
| 12345 dynamic v; |
| 12346 } |
| 12347 bool f() {} |
| 12348 '''); |
| 12349 } |
| 4772 } | 12350 } |
| 4773 | 12351 |
| 4774 test_syntheticFunctionType_inGenericFunction() { | 12352 test_syntheticFunctionType_inGenericFunction() { |
| 4775 checkLibrary(''' | 12353 var library = checkLibrary(''' |
| 4776 void f<T, U>(bool b) { | 12354 void f<T, U>(bool b) { |
| 4777 var v = b ? (T t, U u) => 0 : (T t, U u) => 1; | 12355 var v = b ? (T t, U u) => 0 : (T t, U u) => 1; |
| 4778 } | 12356 } |
| 4779 '''); | 12357 '''); |
| 12358 if (isStrongMode) { |
| 12359 checkElementText( |
| 12360 library, |
| 12361 r''' |
| 12362 void f<T, U>(bool b) {} |
| 12363 '''); |
| 12364 } else { |
| 12365 checkElementText( |
| 12366 library, |
| 12367 r''' |
| 12368 void f<T, U>(bool b) {} |
| 12369 '''); |
| 12370 } |
| 4780 } | 12371 } |
| 4781 | 12372 |
| 4782 test_syntheticFunctionType_noArguments() { | 12373 test_syntheticFunctionType_noArguments() { |
| 4783 checkLibrary(''' | 12374 var library = checkLibrary(''' |
| 4784 final v = f() ? () => 0 : () => 1; | 12375 final v = f() ? () => 0 : () => 1; |
| 4785 bool f() => true; | 12376 bool f() => true; |
| 4786 '''); | 12377 '''); |
| 12378 if (isStrongMode) { |
| 12379 checkElementText( |
| 12380 library, |
| 12381 r''' |
| 12382 '''); |
| 12383 } else { |
| 12384 checkElementText( |
| 12385 library, |
| 12386 r''' |
| 12387 final dynamic v; |
| 12388 bool f() {} |
| 12389 '''); |
| 12390 } |
| 4787 } | 12391 } |
| 4788 | 12392 |
| 4789 test_syntheticFunctionType_withArguments() { | 12393 test_syntheticFunctionType_withArguments() { |
| 4790 checkLibrary(''' | 12394 var library = checkLibrary(''' |
| 4791 final v = f() ? (int x, String y) => 0 : (int x, String y) => 1; | 12395 final v = f() ? (int x, String y) => 0 : (int x, String y) => 1; |
| 4792 bool f() => true; | 12396 bool f() => true; |
| 4793 '''); | 12397 '''); |
| 12398 if (isStrongMode) { |
| 12399 checkElementText( |
| 12400 library, |
| 12401 r''' |
| 12402 '''); |
| 12403 } else { |
| 12404 checkElementText( |
| 12405 library, |
| 12406 r''' |
| 12407 final dynamic v; |
| 12408 bool f() {} |
| 12409 '''); |
| 12410 } |
| 4794 } | 12411 } |
| 4795 | 12412 |
| 4796 test_type_arguments_explicit_dynamic_dynamic() { | 12413 test_type_arguments_explicit_dynamic_dynamic() { |
| 4797 checkLibrary('Map<dynamic, dynamic> m;'); | 12414 var library = checkLibrary('Map<dynamic, dynamic> m;'); |
| 12415 if (isStrongMode) { |
| 12416 checkElementText( |
| 12417 library, |
| 12418 r''' |
| 12419 Map<dynamic, dynamic> m; |
| 12420 '''); |
| 12421 } else { |
| 12422 checkElementText( |
| 12423 library, |
| 12424 r''' |
| 12425 Map<dynamic, dynamic> m; |
| 12426 '''); |
| 12427 } |
| 4798 } | 12428 } |
| 4799 | 12429 |
| 4800 test_type_arguments_explicit_dynamic_int() { | 12430 test_type_arguments_explicit_dynamic_int() { |
| 4801 checkLibrary('Map<dynamic, int> m;'); | 12431 var library = checkLibrary('Map<dynamic, int> m;'); |
| 12432 if (isStrongMode) { |
| 12433 checkElementText( |
| 12434 library, |
| 12435 r''' |
| 12436 Map<dynamic, int> m; |
| 12437 '''); |
| 12438 } else { |
| 12439 checkElementText( |
| 12440 library, |
| 12441 r''' |
| 12442 Map<dynamic, int> m; |
| 12443 '''); |
| 12444 } |
| 4802 } | 12445 } |
| 4803 | 12446 |
| 4804 test_type_arguments_explicit_String_dynamic() { | 12447 test_type_arguments_explicit_String_dynamic() { |
| 4805 checkLibrary('Map<String, dynamic> m;'); | 12448 var library = checkLibrary('Map<String, dynamic> m;'); |
| 12449 if (isStrongMode) { |
| 12450 checkElementText( |
| 12451 library, |
| 12452 r''' |
| 12453 Map<String, dynamic> m; |
| 12454 '''); |
| 12455 } else { |
| 12456 checkElementText( |
| 12457 library, |
| 12458 r''' |
| 12459 Map<String, dynamic> m; |
| 12460 '''); |
| 12461 } |
| 4806 } | 12462 } |
| 4807 | 12463 |
| 4808 test_type_arguments_explicit_String_int() { | 12464 test_type_arguments_explicit_String_int() { |
| 4809 checkLibrary('Map<String, int> m;'); | 12465 var library = checkLibrary('Map<String, int> m;'); |
| 12466 if (isStrongMode) { |
| 12467 checkElementText( |
| 12468 library, |
| 12469 r''' |
| 12470 Map<String, int> m; |
| 12471 '''); |
| 12472 } else { |
| 12473 checkElementText( |
| 12474 library, |
| 12475 r''' |
| 12476 Map<String, int> m; |
| 12477 '''); |
| 12478 } |
| 4810 } | 12479 } |
| 4811 | 12480 |
| 4812 test_type_arguments_implicit() { | 12481 test_type_arguments_implicit() { |
| 4813 checkLibrary('Map m;'); | 12482 var library = checkLibrary('Map m;'); |
| 12483 if (isStrongMode) { |
| 12484 checkElementText( |
| 12485 library, |
| 12486 r''' |
| 12487 Map<dynamic, dynamic> m; |
| 12488 '''); |
| 12489 } else { |
| 12490 checkElementText( |
| 12491 library, |
| 12492 r''' |
| 12493 Map<dynamic, dynamic> m; |
| 12494 '''); |
| 12495 } |
| 4814 } | 12496 } |
| 4815 | 12497 |
| 4816 test_type_dynamic() { | 12498 test_type_dynamic() { |
| 4817 checkLibrary('dynamic d;'); | 12499 var library = checkLibrary('dynamic d;'); |
| 12500 if (isStrongMode) { |
| 12501 checkElementText( |
| 12502 library, |
| 12503 r''' |
| 12504 dynamic d; |
| 12505 '''); |
| 12506 } else { |
| 12507 checkElementText( |
| 12508 library, |
| 12509 r''' |
| 12510 dynamic d; |
| 12511 '''); |
| 12512 } |
| 4818 } | 12513 } |
| 4819 | 12514 |
| 4820 test_type_invalid_topLevelVariableElement_asType() { | 12515 test_type_invalid_topLevelVariableElement_asType() { |
| 4821 checkLibrary( | 12516 var library = checkLibrary( |
| 4822 ''' | 12517 ''' |
| 4823 class C<T extends V> {} | 12518 class C<T extends V> {} |
| 4824 typedef V F(V p); | 12519 typedef V F(V p); |
| 4825 V f(V p) {} | 12520 V f(V p) {} |
| 4826 V V2 = null; | 12521 V V2 = null; |
| 4827 int V = 0; | 12522 int V = 0; |
| 4828 ''', | 12523 ''', |
| 4829 allowErrors: true); | 12524 allowErrors: true); |
| 12525 if (isStrongMode) { |
| 12526 checkElementText( |
| 12527 library, |
| 12528 r''' |
| 12529 typedef dynamic F(dynamic p); |
| 12530 class C<T extends dynamic> { |
| 12531 } |
| 12532 dynamic V2; |
| 12533 int V; |
| 12534 dynamic f(dynamic p) {} |
| 12535 '''); |
| 12536 } else { |
| 12537 checkElementText( |
| 12538 library, |
| 12539 r''' |
| 12540 typedef dynamic F(dynamic p); |
| 12541 class C<T extends dynamic> { |
| 12542 } |
| 12543 dynamic V2; |
| 12544 int V; |
| 12545 dynamic f(dynamic p) {} |
| 12546 '''); |
| 12547 } |
| 4830 } | 12548 } |
| 4831 | 12549 |
| 4832 test_type_invalid_topLevelVariableElement_asTypeArgument() { | 12550 test_type_invalid_topLevelVariableElement_asTypeArgument() { |
| 4833 checkLibrary( | 12551 var library = checkLibrary( |
| 4834 ''' | 12552 ''' |
| 4835 var V; | 12553 var V; |
| 4836 static List<V> V2; | 12554 static List<V> V2; |
| 4837 ''', | 12555 ''', |
| 4838 allowErrors: true); | 12556 allowErrors: true); |
| 12557 if (isStrongMode) { |
| 12558 checkElementText( |
| 12559 library, |
| 12560 r''' |
| 12561 dynamic V; |
| 12562 List<dynamic> V2; |
| 12563 '''); |
| 12564 } else { |
| 12565 checkElementText( |
| 12566 library, |
| 12567 r''' |
| 12568 dynamic V; |
| 12569 List<dynamic> V2; |
| 12570 '''); |
| 12571 } |
| 4839 } | 12572 } |
| 4840 | 12573 |
| 4841 test_type_invalid_typeParameter_asPrefix() { | 12574 test_type_invalid_typeParameter_asPrefix() { |
| 4842 checkLibrary( | 12575 var library = checkLibrary( |
| 4843 ''' | 12576 ''' |
| 4844 class C<T> { | 12577 class C<T> { |
| 4845 m(T.K p) {} | 12578 m(T.K p) {} |
| 4846 } | 12579 } |
| 4847 ''', | 12580 ''', |
| 4848 allowErrors: true); | 12581 allowErrors: true); |
| 12582 if (isStrongMode) { |
| 12583 checkElementText( |
| 12584 library, |
| 12585 r''' |
| 12586 class C<T> { |
| 12587 dynamic m(dynamic p) {} |
| 12588 } |
| 12589 '''); |
| 12590 } else { |
| 12591 checkElementText( |
| 12592 library, |
| 12593 r''' |
| 12594 class C<T> { |
| 12595 dynamic m(dynamic p) {} |
| 12596 } |
| 12597 '''); |
| 12598 } |
| 4849 } | 12599 } |
| 4850 | 12600 |
| 4851 test_type_reference_lib_to_lib() { | 12601 test_type_reference_lib_to_lib() { |
| 4852 checkLibrary('class C {} enum E { v } typedef F(); C c; E e; F f;'); | 12602 var library = |
| 12603 checkLibrary('class C {} enum E { v } typedef F(); C c; E e; F f;'); |
| 12604 if (isStrongMode) { |
| 12605 checkElementText( |
| 12606 library, |
| 12607 r''' |
| 12608 typedef dynamic F(); |
| 12609 enum E { |
| 12610 final int index; |
| 12611 static const List<E> values; |
| 12612 static const E v; |
| 12613 } |
| 12614 class C { |
| 12615 } |
| 12616 C c; |
| 12617 E e; |
| 12618 F f; |
| 12619 '''); |
| 12620 } else { |
| 12621 checkElementText( |
| 12622 library, |
| 12623 r''' |
| 12624 typedef dynamic F(); |
| 12625 enum E { |
| 12626 final int index; |
| 12627 static const List<E> values; |
| 12628 static const E v; |
| 12629 } |
| 12630 class C { |
| 12631 } |
| 12632 C c; |
| 12633 E e; |
| 12634 F f; |
| 12635 '''); |
| 12636 } |
| 4853 } | 12637 } |
| 4854 | 12638 |
| 4855 test_type_reference_lib_to_part() { | 12639 test_type_reference_lib_to_part() { |
| 4856 addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();'); | 12640 addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();'); |
| 4857 checkLibrary('library l; part "a.dart"; C c; E e; F f;'); | 12641 var library = checkLibrary('library l; part "a.dart"; C c; E e; F f;'); |
| 12642 if (isStrongMode) { |
| 12643 checkElementText( |
| 12644 library, |
| 12645 r''' |
| 12646 library l; |
| 12647 part 'a.dart'; |
| 12648 C c; |
| 12649 E e; |
| 12650 F f; |
| 12651 -------------------- |
| 12652 unit: a.dart |
| 12653 |
| 12654 typedef dynamic F(); |
| 12655 enum E { |
| 12656 final int index; |
| 12657 static const List<E> values; |
| 12658 static const E v; |
| 12659 } |
| 12660 class C { |
| 12661 } |
| 12662 '''); |
| 12663 } else { |
| 12664 checkElementText( |
| 12665 library, |
| 12666 r''' |
| 12667 library l; |
| 12668 part 'a.dart'; |
| 12669 C c; |
| 12670 E e; |
| 12671 F f; |
| 12672 -------------------- |
| 12673 unit: a.dart |
| 12674 |
| 12675 typedef dynamic F(); |
| 12676 enum E { |
| 12677 final int index; |
| 12678 static const List<E> values; |
| 12679 static const E v; |
| 12680 } |
| 12681 class C { |
| 12682 } |
| 12683 '''); |
| 12684 } |
| 4858 } | 12685 } |
| 4859 | 12686 |
| 4860 test_type_reference_part_to_lib() { | 12687 test_type_reference_part_to_lib() { |
| 4861 addSource('/a.dart', 'part of l; C c; E e; F f;'); | 12688 addSource('/a.dart', 'part of l; C c; E e; F f;'); |
| 4862 checkLibrary( | 12689 var library = checkLibrary( |
| 4863 'library l; part "a.dart"; class C {} enum E { v } typedef F();'); | 12690 'library l; part "a.dart"; class C {} enum E { v } typedef F();'); |
| 12691 if (isStrongMode) { |
| 12692 checkElementText( |
| 12693 library, |
| 12694 r''' |
| 12695 library l; |
| 12696 part 'a.dart'; |
| 12697 typedef dynamic F(); |
| 12698 enum E { |
| 12699 final int index; |
| 12700 static const List<E> values; |
| 12701 static const E v; |
| 12702 } |
| 12703 class C { |
| 12704 } |
| 12705 -------------------- |
| 12706 unit: a.dart |
| 12707 |
| 12708 C c; |
| 12709 E e; |
| 12710 F f; |
| 12711 '''); |
| 12712 } else { |
| 12713 checkElementText( |
| 12714 library, |
| 12715 r''' |
| 12716 library l; |
| 12717 part 'a.dart'; |
| 12718 typedef dynamic F(); |
| 12719 enum E { |
| 12720 final int index; |
| 12721 static const List<E> values; |
| 12722 static const E v; |
| 12723 } |
| 12724 class C { |
| 12725 } |
| 12726 -------------------- |
| 12727 unit: a.dart |
| 12728 |
| 12729 C c; |
| 12730 E e; |
| 12731 F f; |
| 12732 '''); |
| 12733 } |
| 4864 } | 12734 } |
| 4865 | 12735 |
| 4866 test_type_reference_part_to_other_part() { | 12736 test_type_reference_part_to_other_part() { |
| 4867 addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();'); | 12737 addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();'); |
| 4868 addSource('/b.dart', 'part of l; C c; E e; F f;'); | 12738 addSource('/b.dart', 'part of l; C c; E e; F f;'); |
| 4869 checkLibrary('library l; part "a.dart"; part "b.dart";'); | 12739 var library = checkLibrary('library l; part "a.dart"; part "b.dart";'); |
| 12740 if (isStrongMode) { |
| 12741 checkElementText( |
| 12742 library, |
| 12743 r''' |
| 12744 library l; |
| 12745 part 'a.dart'; |
| 12746 part 'b.dart'; |
| 12747 -------------------- |
| 12748 unit: a.dart |
| 12749 |
| 12750 typedef dynamic F(); |
| 12751 enum E { |
| 12752 final int index; |
| 12753 static const List<E> values; |
| 12754 static const E v; |
| 12755 } |
| 12756 class C { |
| 12757 } |
| 12758 -------------------- |
| 12759 unit: b.dart |
| 12760 |
| 12761 C c; |
| 12762 E e; |
| 12763 F f; |
| 12764 '''); |
| 12765 } else { |
| 12766 checkElementText( |
| 12767 library, |
| 12768 r''' |
| 12769 library l; |
| 12770 part 'a.dart'; |
| 12771 part 'b.dart'; |
| 12772 -------------------- |
| 12773 unit: a.dart |
| 12774 |
| 12775 typedef dynamic F(); |
| 12776 enum E { |
| 12777 final int index; |
| 12778 static const List<E> values; |
| 12779 static const E v; |
| 12780 } |
| 12781 class C { |
| 12782 } |
| 12783 -------------------- |
| 12784 unit: b.dart |
| 12785 |
| 12786 C c; |
| 12787 E e; |
| 12788 F f; |
| 12789 '''); |
| 12790 } |
| 4870 } | 12791 } |
| 4871 | 12792 |
| 4872 test_type_reference_part_to_part() { | 12793 test_type_reference_part_to_part() { |
| 4873 addSource('/a.dart', | 12794 addSource('/a.dart', |
| 4874 'part of l; class C {} enum E { v } typedef F(); C c; E e; F f;'); | 12795 'part of l; class C {} enum E { v } typedef F(); C c; E e; F f;'); |
| 4875 checkLibrary('library l; part "a.dart";'); | 12796 var library = checkLibrary('library l; part "a.dart";'); |
| 12797 if (isStrongMode) { |
| 12798 checkElementText( |
| 12799 library, |
| 12800 r''' |
| 12801 library l; |
| 12802 part 'a.dart'; |
| 12803 -------------------- |
| 12804 unit: a.dart |
| 12805 |
| 12806 typedef dynamic F(); |
| 12807 enum E { |
| 12808 final int index; |
| 12809 static const List<E> values; |
| 12810 static const E v; |
| 12811 } |
| 12812 class C { |
| 12813 } |
| 12814 C c; |
| 12815 E e; |
| 12816 F f; |
| 12817 '''); |
| 12818 } else { |
| 12819 checkElementText( |
| 12820 library, |
| 12821 r''' |
| 12822 library l; |
| 12823 part 'a.dart'; |
| 12824 -------------------- |
| 12825 unit: a.dart |
| 12826 |
| 12827 typedef dynamic F(); |
| 12828 enum E { |
| 12829 final int index; |
| 12830 static const List<E> values; |
| 12831 static const E v; |
| 12832 } |
| 12833 class C { |
| 12834 } |
| 12835 C c; |
| 12836 E e; |
| 12837 F f; |
| 12838 '''); |
| 12839 } |
| 4876 } | 12840 } |
| 4877 | 12841 |
| 4878 test_type_reference_to_class() { | 12842 test_type_reference_to_class() { |
| 4879 checkLibrary('class C {} C c;'); | 12843 var library = checkLibrary('class C {} C c;'); |
| 12844 if (isStrongMode) { |
| 12845 checkElementText( |
| 12846 library, |
| 12847 r''' |
| 12848 class C { |
| 12849 } |
| 12850 C c; |
| 12851 '''); |
| 12852 } else { |
| 12853 checkElementText( |
| 12854 library, |
| 12855 r''' |
| 12856 class C { |
| 12857 } |
| 12858 C c; |
| 12859 '''); |
| 12860 } |
| 4880 } | 12861 } |
| 4881 | 12862 |
| 4882 test_type_reference_to_class_with_type_arguments() { | 12863 test_type_reference_to_class_with_type_arguments() { |
| 4883 checkLibrary('class C<T, U> {} C<int, String> c;'); | 12864 var library = checkLibrary('class C<T, U> {} C<int, String> c;'); |
| 12865 if (isStrongMode) { |
| 12866 checkElementText( |
| 12867 library, |
| 12868 r''' |
| 12869 class C<T, U> { |
| 12870 } |
| 12871 C<int, String> c; |
| 12872 '''); |
| 12873 } else { |
| 12874 checkElementText( |
| 12875 library, |
| 12876 r''' |
| 12877 class C<T, U> { |
| 12878 } |
| 12879 C<int, String> c; |
| 12880 '''); |
| 12881 } |
| 4884 } | 12882 } |
| 4885 | 12883 |
| 4886 test_type_reference_to_class_with_type_arguments_implicit() { | 12884 test_type_reference_to_class_with_type_arguments_implicit() { |
| 4887 checkLibrary('class C<T, U> {} C c;'); | 12885 var library = checkLibrary('class C<T, U> {} C c;'); |
| 12886 if (isStrongMode) { |
| 12887 checkElementText( |
| 12888 library, |
| 12889 r''' |
| 12890 class C<T, U> { |
| 12891 } |
| 12892 C<dynamic, dynamic> c; |
| 12893 '''); |
| 12894 } else { |
| 12895 checkElementText( |
| 12896 library, |
| 12897 r''' |
| 12898 class C<T, U> { |
| 12899 } |
| 12900 C<dynamic, dynamic> c; |
| 12901 '''); |
| 12902 } |
| 4888 } | 12903 } |
| 4889 | 12904 |
| 4890 test_type_reference_to_enum() { | 12905 test_type_reference_to_enum() { |
| 4891 checkLibrary('enum E { v } E e;'); | 12906 var library = checkLibrary('enum E { v } E e;'); |
| 12907 if (isStrongMode) { |
| 12908 checkElementText( |
| 12909 library, |
| 12910 r''' |
| 12911 enum E { |
| 12912 final int index; |
| 12913 static const List<E> values; |
| 12914 static const E v; |
| 12915 } |
| 12916 E e; |
| 12917 '''); |
| 12918 } else { |
| 12919 checkElementText( |
| 12920 library, |
| 12921 r''' |
| 12922 enum E { |
| 12923 final int index; |
| 12924 static const List<E> values; |
| 12925 static const E v; |
| 12926 } |
| 12927 E e; |
| 12928 '''); |
| 12929 } |
| 4892 } | 12930 } |
| 4893 | 12931 |
| 4894 test_type_reference_to_import() { | 12932 test_type_reference_to_import() { |
| 4895 addLibrarySource('/a.dart', 'class C {} enum E { v }; typedef F();'); | 12933 addLibrarySource('/a.dart', 'class C {} enum E { v }; typedef F();'); |
| 4896 checkLibrary('import "a.dart"; C c; E e; F f;'); | 12934 var library = checkLibrary('import "a.dart"; C c; E e; F f;'); |
| 12935 if (isStrongMode) { |
| 12936 checkElementText( |
| 12937 library, |
| 12938 r''' |
| 12939 import 'a.dart'; |
| 12940 C c; |
| 12941 E e; |
| 12942 F f; |
| 12943 '''); |
| 12944 } else { |
| 12945 checkElementText( |
| 12946 library, |
| 12947 r''' |
| 12948 import 'a.dart'; |
| 12949 C c; |
| 12950 E e; |
| 12951 F f; |
| 12952 '''); |
| 12953 } |
| 4897 } | 12954 } |
| 4898 | 12955 |
| 4899 test_type_reference_to_import_export() { | 12956 test_type_reference_to_import_export() { |
| 4900 addLibrarySource('/a.dart', 'export "b.dart";'); | 12957 addLibrarySource('/a.dart', 'export "b.dart";'); |
| 4901 addLibrarySource('/b.dart', 'class C {} enum E { v } typedef F();'); | 12958 addLibrarySource('/b.dart', 'class C {} enum E { v } typedef F();'); |
| 4902 checkLibrary('import "a.dart"; C c; E e; F f;'); | 12959 var library = checkLibrary('import "a.dart"; C c; E e; F f;'); |
| 12960 if (isStrongMode) { |
| 12961 checkElementText( |
| 12962 library, |
| 12963 r''' |
| 12964 import 'a.dart'; |
| 12965 C c; |
| 12966 E e; |
| 12967 F f; |
| 12968 '''); |
| 12969 } else { |
| 12970 checkElementText( |
| 12971 library, |
| 12972 r''' |
| 12973 import 'a.dart'; |
| 12974 C c; |
| 12975 E e; |
| 12976 F f; |
| 12977 '''); |
| 12978 } |
| 4903 } | 12979 } |
| 4904 | 12980 |
| 4905 test_type_reference_to_import_export_export() { | 12981 test_type_reference_to_import_export_export() { |
| 4906 addLibrarySource('/a.dart', 'export "b.dart";'); | 12982 addLibrarySource('/a.dart', 'export "b.dart";'); |
| 4907 addLibrarySource('/b.dart', 'export "c.dart";'); | 12983 addLibrarySource('/b.dart', 'export "c.dart";'); |
| 4908 addLibrarySource('/c.dart', 'class C {} enum E { v } typedef F();'); | 12984 addLibrarySource('/c.dart', 'class C {} enum E { v } typedef F();'); |
| 4909 checkLibrary('import "a.dart"; C c; E e; F f;'); | 12985 var library = checkLibrary('import "a.dart"; C c; E e; F f;'); |
| 12986 if (isStrongMode) { |
| 12987 checkElementText( |
| 12988 library, |
| 12989 r''' |
| 12990 import 'a.dart'; |
| 12991 C c; |
| 12992 E e; |
| 12993 F f; |
| 12994 '''); |
| 12995 } else { |
| 12996 checkElementText( |
| 12997 library, |
| 12998 r''' |
| 12999 import 'a.dart'; |
| 13000 C c; |
| 13001 E e; |
| 13002 F f; |
| 13003 '''); |
| 13004 } |
| 4910 } | 13005 } |
| 4911 | 13006 |
| 4912 test_type_reference_to_import_export_export_in_subdirs() { | 13007 test_type_reference_to_import_export_export_in_subdirs() { |
| 4913 addLibrarySource('/a/a.dart', 'export "b/b.dart";'); | 13008 addLibrarySource('/a/a.dart', 'export "b/b.dart";'); |
| 4914 addLibrarySource('/a/b/b.dart', 'export "../c/c.dart";'); | 13009 addLibrarySource('/a/b/b.dart', 'export "../c/c.dart";'); |
| 4915 addLibrarySource('/a/c/c.dart', 'class C {} enum E { v } typedef F();'); | 13010 addLibrarySource('/a/c/c.dart', 'class C {} enum E { v } typedef F();'); |
| 4916 checkLibrary('import "a/a.dart"; C c; E e; F f;'); | 13011 var library = checkLibrary('import "a/a.dart"; C c; E e; F f;'); |
| 13012 if (isStrongMode) { |
| 13013 checkElementText( |
| 13014 library, |
| 13015 r''' |
| 13016 import 'a/a.dart'; |
| 13017 C c; |
| 13018 E e; |
| 13019 F f; |
| 13020 '''); |
| 13021 } else { |
| 13022 checkElementText( |
| 13023 library, |
| 13024 r''' |
| 13025 import 'a/a.dart'; |
| 13026 C c; |
| 13027 E e; |
| 13028 F f; |
| 13029 '''); |
| 13030 } |
| 4917 } | 13031 } |
| 4918 | 13032 |
| 4919 test_type_reference_to_import_export_in_subdirs() { | 13033 test_type_reference_to_import_export_in_subdirs() { |
| 4920 addLibrarySource('/a/a.dart', 'export "b/b.dart";'); | 13034 addLibrarySource('/a/a.dart', 'export "b/b.dart";'); |
| 4921 addLibrarySource('/a/b/b.dart', 'class C {} enum E { v } typedef F();'); | 13035 addLibrarySource('/a/b/b.dart', 'class C {} enum E { v } typedef F();'); |
| 4922 checkLibrary('import "a/a.dart"; C c; E e; F f;'); | 13036 var library = checkLibrary('import "a/a.dart"; C c; E e; F f;'); |
| 13037 if (isStrongMode) { |
| 13038 checkElementText( |
| 13039 library, |
| 13040 r''' |
| 13041 import 'a/a.dart'; |
| 13042 C c; |
| 13043 E e; |
| 13044 F f; |
| 13045 '''); |
| 13046 } else { |
| 13047 checkElementText( |
| 13048 library, |
| 13049 r''' |
| 13050 import 'a/a.dart'; |
| 13051 C c; |
| 13052 E e; |
| 13053 F f; |
| 13054 '''); |
| 13055 } |
| 4923 } | 13056 } |
| 4924 | 13057 |
| 4925 test_type_reference_to_import_part() { | 13058 test_type_reference_to_import_part() { |
| 4926 addLibrarySource('/a.dart', 'library l; part "b.dart";'); | 13059 addLibrarySource('/a.dart', 'library l; part "b.dart";'); |
| 4927 addSource('/b.dart', 'part of l; class C {} enum E { v } typedef F();'); | 13060 addSource('/b.dart', 'part of l; class C {} enum E { v } typedef F();'); |
| 4928 checkLibrary('import "a.dart"; C c; E e; F f;'); | 13061 var library = checkLibrary('import "a.dart"; C c; E e; F f;'); |
| 13062 if (isStrongMode) { |
| 13063 checkElementText( |
| 13064 library, |
| 13065 r''' |
| 13066 import 'a.dart'; |
| 13067 C c; |
| 13068 E e; |
| 13069 F f; |
| 13070 '''); |
| 13071 } else { |
| 13072 checkElementText( |
| 13073 library, |
| 13074 r''' |
| 13075 import 'a.dart'; |
| 13076 C c; |
| 13077 E e; |
| 13078 F f; |
| 13079 '''); |
| 13080 } |
| 4929 } | 13081 } |
| 4930 | 13082 |
| 4931 test_type_reference_to_import_part2() { | 13083 test_type_reference_to_import_part2() { |
| 4932 addLibrarySource('/a.dart', 'library l; part "p1.dart"; part "p2.dart";'); | 13084 addLibrarySource('/a.dart', 'library l; part "p1.dart"; part "p2.dart";'); |
| 4933 addSource('/p1.dart', 'part of l; class C1 {}'); | 13085 addSource('/p1.dart', 'part of l; class C1 {}'); |
| 4934 addSource('/p2.dart', 'part of l; class C2 {}'); | 13086 addSource('/p2.dart', 'part of l; class C2 {}'); |
| 4935 checkLibrary('import "a.dart"; C1 c1; C2 c2;'); | 13087 var library = checkLibrary('import "a.dart"; C1 c1; C2 c2;'); |
| 13088 if (isStrongMode) { |
| 13089 checkElementText( |
| 13090 library, |
| 13091 r''' |
| 13092 import 'a.dart'; |
| 13093 C1 c1; |
| 13094 C2 c2; |
| 13095 '''); |
| 13096 } else { |
| 13097 checkElementText( |
| 13098 library, |
| 13099 r''' |
| 13100 import 'a.dart'; |
| 13101 C1 c1; |
| 13102 C2 c2; |
| 13103 '''); |
| 13104 } |
| 4936 } | 13105 } |
| 4937 | 13106 |
| 4938 test_type_reference_to_import_part_in_subdir() { | 13107 test_type_reference_to_import_part_in_subdir() { |
| 4939 addLibrarySource('/a/b.dart', 'library l; part "c.dart";'); | 13108 addLibrarySource('/a/b.dart', 'library l; part "c.dart";'); |
| 4940 addSource('/a/c.dart', 'part of l; class C {} enum E { v } typedef F();'); | 13109 addSource('/a/c.dart', 'part of l; class C {} enum E { v } typedef F();'); |
| 4941 checkLibrary('import "a/b.dart"; C c; E e; F f;'); | 13110 var library = checkLibrary('import "a/b.dart"; C c; E e; F f;'); |
| 13111 if (isStrongMode) { |
| 13112 checkElementText( |
| 13113 library, |
| 13114 r''' |
| 13115 import 'a/b.dart'; |
| 13116 C c; |
| 13117 E e; |
| 13118 F f; |
| 13119 '''); |
| 13120 } else { |
| 13121 checkElementText( |
| 13122 library, |
| 13123 r''' |
| 13124 import 'a/b.dart'; |
| 13125 C c; |
| 13126 E e; |
| 13127 F f; |
| 13128 '''); |
| 13129 } |
| 4942 } | 13130 } |
| 4943 | 13131 |
| 4944 test_type_reference_to_import_relative() { | 13132 test_type_reference_to_import_relative() { |
| 4945 addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();'); | 13133 addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();'); |
| 4946 checkLibrary('import "a.dart"; C c; E e; F f;'); | 13134 var library = checkLibrary('import "a.dart"; C c; E e; F f;'); |
| 13135 if (isStrongMode) { |
| 13136 checkElementText( |
| 13137 library, |
| 13138 r''' |
| 13139 import 'a.dart'; |
| 13140 C c; |
| 13141 E e; |
| 13142 F f; |
| 13143 '''); |
| 13144 } else { |
| 13145 checkElementText( |
| 13146 library, |
| 13147 r''' |
| 13148 import 'a.dart'; |
| 13149 C c; |
| 13150 E e; |
| 13151 F f; |
| 13152 '''); |
| 13153 } |
| 4947 } | 13154 } |
| 4948 | 13155 |
| 4949 test_type_reference_to_typedef() { | 13156 test_type_reference_to_typedef() { |
| 4950 checkLibrary('typedef F(); F f;'); | 13157 var library = checkLibrary('typedef F(); F f;'); |
| 13158 if (isStrongMode) { |
| 13159 checkElementText( |
| 13160 library, |
| 13161 r''' |
| 13162 typedef dynamic F(); |
| 13163 F f; |
| 13164 '''); |
| 13165 } else { |
| 13166 checkElementText( |
| 13167 library, |
| 13168 r''' |
| 13169 typedef dynamic F(); |
| 13170 F f; |
| 13171 '''); |
| 13172 } |
| 4951 } | 13173 } |
| 4952 | 13174 |
| 4953 test_type_reference_to_typedef_with_type_arguments() { | 13175 test_type_reference_to_typedef_with_type_arguments() { |
| 4954 checkLibrary('typedef U F<T, U>(T t); F<int, String> f;'); | 13176 var library = checkLibrary('typedef U F<T, U>(T t); F<int, String> f;'); |
| 13177 if (isStrongMode) { |
| 13178 checkElementText( |
| 13179 library, |
| 13180 r''' |
| 13181 typedef U F<T, U>(T t); |
| 13182 F f; |
| 13183 '''); |
| 13184 } else { |
| 13185 checkElementText( |
| 13186 library, |
| 13187 r''' |
| 13188 typedef U F<T, U>(T t); |
| 13189 F f; |
| 13190 '''); |
| 13191 } |
| 4955 } | 13192 } |
| 4956 | 13193 |
| 4957 test_type_reference_to_typedef_with_type_arguments_implicit() { | 13194 test_type_reference_to_typedef_with_type_arguments_implicit() { |
| 4958 checkLibrary('typedef U F<T, U>(T t); F f;'); | 13195 var library = checkLibrary('typedef U F<T, U>(T t); F f;'); |
| 13196 if (isStrongMode) { |
| 13197 checkElementText( |
| 13198 library, |
| 13199 r''' |
| 13200 typedef U F<T, U>(T t); |
| 13201 F f; |
| 13202 '''); |
| 13203 } else { |
| 13204 checkElementText( |
| 13205 library, |
| 13206 r''' |
| 13207 typedef U F<T, U>(T t); |
| 13208 F f; |
| 13209 '''); |
| 13210 } |
| 4959 } | 13211 } |
| 4960 | 13212 |
| 4961 test_type_unresolved() { | 13213 test_type_unresolved() { |
| 4962 checkLibrary('C c;', allowErrors: true); | 13214 var library = checkLibrary('C c;', allowErrors: true); |
| 13215 if (isStrongMode) { |
| 13216 checkElementText( |
| 13217 library, |
| 13218 r''' |
| 13219 dynamic c; |
| 13220 '''); |
| 13221 } else { |
| 13222 checkElementText( |
| 13223 library, |
| 13224 r''' |
| 13225 dynamic c; |
| 13226 '''); |
| 13227 } |
| 4963 } | 13228 } |
| 4964 | 13229 |
| 4965 test_type_unresolved_prefixed() { | 13230 test_type_unresolved_prefixed() { |
| 4966 checkLibrary('import "dart:core" as core; core.C c;', allowErrors: true); | 13231 var library = checkLibrary('import "dart:core" as core; core.C c;', |
| 13232 allowErrors: true); |
| 13233 if (isStrongMode) { |
| 13234 checkElementText( |
| 13235 library, |
| 13236 r''' |
| 13237 import 'dart:core' as core; |
| 13238 dynamic c; |
| 13239 '''); |
| 13240 } else { |
| 13241 checkElementText( |
| 13242 library, |
| 13243 r''' |
| 13244 import 'dart:core' as core; |
| 13245 dynamic c; |
| 13246 '''); |
| 13247 } |
| 4967 } | 13248 } |
| 4968 | 13249 |
| 4969 test_typedef_documented() { | 13250 test_typedef_documented() { |
| 4970 checkLibrary(''' | 13251 var library = checkLibrary(''' |
| 4971 // Extra comment so doc comment offset != 0 | 13252 // Extra comment so doc comment offset != 0 |
| 4972 /** | 13253 /** |
| 4973 * Docs | 13254 * Docs |
| 4974 */ | 13255 */ |
| 4975 typedef F();'''); | 13256 typedef F();'''); |
| 13257 if (isStrongMode) { |
| 13258 checkElementText( |
| 13259 library, |
| 13260 r''' |
| 13261 /** |
| 13262 * Docs |
| 13263 */ |
| 13264 typedef dynamic F(); |
| 13265 '''); |
| 13266 } else { |
| 13267 checkElementText( |
| 13268 library, |
| 13269 r''' |
| 13270 /** |
| 13271 * Docs |
| 13272 */ |
| 13273 typedef dynamic F(); |
| 13274 '''); |
| 13275 } |
| 4976 } | 13276 } |
| 4977 | 13277 |
| 4978 test_typedef_parameter_parameters() { | 13278 test_typedef_parameter_parameters() { |
| 4979 checkLibrary('typedef F(g(x, y));'); | 13279 var library = checkLibrary('typedef F(g(x, y));'); |
| 13280 if (isStrongMode) { |
| 13281 checkElementText( |
| 13282 library, |
| 13283 r''' |
| 13284 typedef dynamic F((dynamic, dynamic) → dynamic g); |
| 13285 '''); |
| 13286 } else { |
| 13287 checkElementText( |
| 13288 library, |
| 13289 r''' |
| 13290 typedef dynamic F((dynamic, dynamic) → dynamic g); |
| 13291 '''); |
| 13292 } |
| 4980 } | 13293 } |
| 4981 | 13294 |
| 4982 test_typedef_parameter_parameters_in_generic_class() { | 13295 test_typedef_parameter_parameters_in_generic_class() { |
| 4983 checkLibrary('typedef F<A, B>(A g(B x));'); | 13296 var library = checkLibrary('typedef F<A, B>(A g(B x));'); |
| 13297 if (isStrongMode) { |
| 13298 checkElementText( |
| 13299 library, |
| 13300 r''' |
| 13301 typedef dynamic F<A, B>((B) → A g); |
| 13302 '''); |
| 13303 } else { |
| 13304 checkElementText( |
| 13305 library, |
| 13306 r''' |
| 13307 typedef dynamic F<A, B>((B) → A g); |
| 13308 '''); |
| 13309 } |
| 4984 } | 13310 } |
| 4985 | 13311 |
| 4986 test_typedef_parameter_return_type() { | 13312 test_typedef_parameter_return_type() { |
| 4987 checkLibrary('typedef F(int g());'); | 13313 var library = checkLibrary('typedef F(int g());'); |
| 13314 if (isStrongMode) { |
| 13315 checkElementText( |
| 13316 library, |
| 13317 r''' |
| 13318 typedef dynamic F(() → int g); |
| 13319 '''); |
| 13320 } else { |
| 13321 checkElementText( |
| 13322 library, |
| 13323 r''' |
| 13324 typedef dynamic F(() → int g); |
| 13325 '''); |
| 13326 } |
| 4988 } | 13327 } |
| 4989 | 13328 |
| 4990 test_typedef_parameter_type() { | 13329 test_typedef_parameter_type() { |
| 4991 checkLibrary('typedef F(int i);'); | 13330 var library = checkLibrary('typedef F(int i);'); |
| 13331 if (isStrongMode) { |
| 13332 checkElementText( |
| 13333 library, |
| 13334 r''' |
| 13335 typedef dynamic F(int i); |
| 13336 '''); |
| 13337 } else { |
| 13338 checkElementText( |
| 13339 library, |
| 13340 r''' |
| 13341 typedef dynamic F(int i); |
| 13342 '''); |
| 13343 } |
| 4992 } | 13344 } |
| 4993 | 13345 |
| 4994 test_typedef_parameter_type_generic() { | 13346 test_typedef_parameter_type_generic() { |
| 4995 checkLibrary('typedef F<T>(T t);'); | 13347 var library = checkLibrary('typedef F<T>(T t);'); |
| 13348 if (isStrongMode) { |
| 13349 checkElementText( |
| 13350 library, |
| 13351 r''' |
| 13352 typedef dynamic F<T>(T t); |
| 13353 '''); |
| 13354 } else { |
| 13355 checkElementText( |
| 13356 library, |
| 13357 r''' |
| 13358 typedef dynamic F<T>(T t); |
| 13359 '''); |
| 13360 } |
| 4996 } | 13361 } |
| 4997 | 13362 |
| 4998 test_typedef_parameters() { | 13363 test_typedef_parameters() { |
| 4999 checkLibrary('typedef F(x, y);'); | 13364 var library = checkLibrary('typedef F(x, y);'); |
| 13365 if (isStrongMode) { |
| 13366 checkElementText( |
| 13367 library, |
| 13368 r''' |
| 13369 typedef dynamic F(dynamic x, dynamic y); |
| 13370 '''); |
| 13371 } else { |
| 13372 checkElementText( |
| 13373 library, |
| 13374 r''' |
| 13375 typedef dynamic F(dynamic x, dynamic y); |
| 13376 '''); |
| 13377 } |
| 5000 } | 13378 } |
| 5001 | 13379 |
| 5002 test_typedef_return_type() { | 13380 test_typedef_return_type() { |
| 5003 checkLibrary('typedef int F();'); | 13381 var library = checkLibrary('typedef int F();'); |
| 13382 if (isStrongMode) { |
| 13383 checkElementText( |
| 13384 library, |
| 13385 r''' |
| 13386 typedef int F(); |
| 13387 '''); |
| 13388 } else { |
| 13389 checkElementText( |
| 13390 library, |
| 13391 r''' |
| 13392 typedef int F(); |
| 13393 '''); |
| 13394 } |
| 5004 } | 13395 } |
| 5005 | 13396 |
| 5006 test_typedef_return_type_generic() { | 13397 test_typedef_return_type_generic() { |
| 5007 checkLibrary('typedef T F<T>();'); | 13398 var library = checkLibrary('typedef T F<T>();'); |
| 13399 if (isStrongMode) { |
| 13400 checkElementText( |
| 13401 library, |
| 13402 r''' |
| 13403 typedef T F<T>(); |
| 13404 '''); |
| 13405 } else { |
| 13406 checkElementText( |
| 13407 library, |
| 13408 r''' |
| 13409 typedef T F<T>(); |
| 13410 '''); |
| 13411 } |
| 5008 } | 13412 } |
| 5009 | 13413 |
| 5010 test_typedef_return_type_implicit() { | 13414 test_typedef_return_type_implicit() { |
| 5011 checkLibrary('typedef F();'); | 13415 var library = checkLibrary('typedef F();'); |
| 13416 if (isStrongMode) { |
| 13417 checkElementText( |
| 13418 library, |
| 13419 r''' |
| 13420 typedef dynamic F(); |
| 13421 '''); |
| 13422 } else { |
| 13423 checkElementText( |
| 13424 library, |
| 13425 r''' |
| 13426 typedef dynamic F(); |
| 13427 '''); |
| 13428 } |
| 5012 } | 13429 } |
| 5013 | 13430 |
| 5014 test_typedef_return_type_void() { | 13431 test_typedef_return_type_void() { |
| 5015 checkLibrary('typedef void F();'); | 13432 var library = checkLibrary('typedef void F();'); |
| 13433 if (isStrongMode) { |
| 13434 checkElementText( |
| 13435 library, |
| 13436 r''' |
| 13437 typedef void F(); |
| 13438 '''); |
| 13439 } else { |
| 13440 checkElementText( |
| 13441 library, |
| 13442 r''' |
| 13443 typedef void F(); |
| 13444 '''); |
| 13445 } |
| 5016 } | 13446 } |
| 5017 | 13447 |
| 5018 test_typedef_type_parameters() { | 13448 test_typedef_type_parameters() { |
| 5019 checkLibrary('typedef U F<T, U>(T t);'); | 13449 var library = checkLibrary('typedef U F<T, U>(T t);'); |
| 13450 if (isStrongMode) { |
| 13451 checkElementText( |
| 13452 library, |
| 13453 r''' |
| 13454 typedef U F<T, U>(T t); |
| 13455 '''); |
| 13456 } else { |
| 13457 checkElementText( |
| 13458 library, |
| 13459 r''' |
| 13460 typedef U F<T, U>(T t); |
| 13461 '''); |
| 13462 } |
| 5020 } | 13463 } |
| 5021 | 13464 |
| 5022 test_typedef_type_parameters_bound() { | 13465 test_typedef_type_parameters_bound() { |
| 5023 checkLibrary('typedef U F<T extends Object, U extends D>(T t); class D {}'); | 13466 var library = checkLibrary( |
| 13467 'typedef U F<T extends Object, U extends D>(T t); class D {}'); |
| 13468 if (isStrongMode) { |
| 13469 checkElementText( |
| 13470 library, |
| 13471 r''' |
| 13472 typedef U F<T extends Object, U extends D>(T t); |
| 13473 class D { |
| 13474 } |
| 13475 '''); |
| 13476 } else { |
| 13477 checkElementText( |
| 13478 library, |
| 13479 r''' |
| 13480 typedef U F<T extends Object, U extends D>(T t); |
| 13481 class D { |
| 13482 } |
| 13483 '''); |
| 13484 } |
| 5024 } | 13485 } |
| 5025 | 13486 |
| 5026 test_typedef_type_parameters_f_bound_complex() { | 13487 test_typedef_type_parameters_f_bound_complex() { |
| 5027 checkLibrary('typedef U F<T extends List<U>, U>(T t);'); | 13488 var library = checkLibrary('typedef U F<T extends List<U>, U>(T t);'); |
| 13489 if (isStrongMode) { |
| 13490 checkElementText( |
| 13491 library, |
| 13492 r''' |
| 13493 typedef U F<T extends List<U>, U>(T t); |
| 13494 '''); |
| 13495 } else { |
| 13496 checkElementText( |
| 13497 library, |
| 13498 r''' |
| 13499 typedef U F<T extends List<U>, U>(T t); |
| 13500 '''); |
| 13501 } |
| 5028 } | 13502 } |
| 5029 | 13503 |
| 5030 test_typedef_type_parameters_f_bound_simple() { | 13504 test_typedef_type_parameters_f_bound_simple() { |
| 5031 checkLibrary('typedef U F<T extends U, U>(T t);'); | 13505 var library = checkLibrary('typedef U F<T extends U, U>(T t);'); |
| 13506 if (isStrongMode) { |
| 13507 checkElementText( |
| 13508 library, |
| 13509 r''' |
| 13510 typedef U F<T extends U, U>(T t); |
| 13511 '''); |
| 13512 } else { |
| 13513 checkElementText( |
| 13514 library, |
| 13515 r''' |
| 13516 typedef U F<T extends U, U>(T t); |
| 13517 '''); |
| 13518 } |
| 5032 } | 13519 } |
| 5033 | 13520 |
| 5034 test_typedefs() { | 13521 test_typedefs() { |
| 5035 checkLibrary('f() {} g() {}'); | 13522 var library = checkLibrary('f() {} g() {}'); |
| 13523 if (isStrongMode) { |
| 13524 checkElementText( |
| 13525 library, |
| 13526 r''' |
| 13527 dynamic f() {} |
| 13528 dynamic g() {} |
| 13529 '''); |
| 13530 } else { |
| 13531 checkElementText( |
| 13532 library, |
| 13533 r''' |
| 13534 dynamic f() {} |
| 13535 dynamic g() {} |
| 13536 '''); |
| 13537 } |
| 5036 } | 13538 } |
| 5037 | 13539 |
| 5038 @failingTest | 13540 @failingTest |
| 5039 test_unresolved_annotation_instanceCreation_argument_super() { | 13541 test_unresolved_annotation_instanceCreation_argument_super() { |
| 5040 // TODO(scheglov) fix https://github.com/dart-lang/sdk/issues/28553 | 13542 // TODO(scheglov) fix https://github.com/dart-lang/sdk/issues/28553 |
| 5041 checkLibrary( | 13543 var library = checkLibrary( |
| 5042 ''' | 13544 ''' |
| 5043 class A { | 13545 class A { |
| 5044 const A(_); | 13546 const A(_); |
| 5045 } | 13547 } |
| 5046 | 13548 |
| 5047 @A(super) | 13549 @A(super) |
| 5048 class C {} | 13550 class C {} |
| 5049 ''', | 13551 ''', |
| 5050 allowErrors: true); | 13552 allowErrors: true); |
| 13553 if (isStrongMode) { |
| 13554 checkElementText( |
| 13555 library, |
| 13556 r''' |
| 13557 class A { |
| 13558 A(_); |
| 13559 } |
| 13560 |
| 13561 class C { |
| 13562 synthetic C(); |
| 13563 } |
| 13564 '''); |
| 13565 } else { |
| 13566 checkElementText( |
| 13567 library, |
| 13568 r''' |
| 13569 class A { |
| 13570 A(_); |
| 13571 } |
| 13572 |
| 13573 class C { |
| 13574 synthetic C(); |
| 13575 } |
| 13576 '''); |
| 13577 } |
| 5051 } | 13578 } |
| 5052 | 13579 |
| 5053 test_unresolved_annotation_instanceCreation_argument_this() { | 13580 test_unresolved_annotation_instanceCreation_argument_this() { |
| 5054 checkLibrary( | 13581 var library = checkLibrary( |
| 5055 ''' | 13582 ''' |
| 5056 class A { | 13583 class A { |
| 5057 const A(_); | 13584 const A(_); |
| 5058 } | 13585 } |
| 5059 | 13586 |
| 5060 @A(this) | 13587 @A(this) |
| 5061 class C {} | 13588 class C {} |
| 5062 ''', | 13589 ''', |
| 5063 allowErrors: true); | 13590 allowErrors: true); |
| 13591 if (isStrongMode) { |
| 13592 checkElementText( |
| 13593 library, |
| 13594 r''' |
| 13595 class A { |
| 13596 const A(dynamic _); |
| 13597 } |
| 13598 @A(this) |
| 13599 class C { |
| 13600 } |
| 13601 '''); |
| 13602 } else { |
| 13603 checkElementText( |
| 13604 library, |
| 13605 r''' |
| 13606 class A { |
| 13607 const A(dynamic _); |
| 13608 } |
| 13609 @A(this) |
| 13610 class C { |
| 13611 } |
| 13612 '''); |
| 13613 } |
| 5064 } | 13614 } |
| 5065 | 13615 |
| 5066 test_unresolved_annotation_namedConstructorCall_noClass() { | 13616 test_unresolved_annotation_namedConstructorCall_noClass() { |
| 5067 checkLibrary('@foo.bar() class C {}', allowErrors: true); | 13617 var library = checkLibrary('@foo.bar() class C {}', allowErrors: true); |
| 13618 if (isStrongMode) { |
| 13619 checkElementText( |
| 13620 library, |
| 13621 r''' |
| 13622 @foo.bar() |
| 13623 class C { |
| 13624 } |
| 13625 '''); |
| 13626 } else { |
| 13627 checkElementText( |
| 13628 library, |
| 13629 r''' |
| 13630 @foo.bar() |
| 13631 class C { |
| 13632 } |
| 13633 '''); |
| 13634 } |
| 5068 } | 13635 } |
| 5069 | 13636 |
| 5070 test_unresolved_annotation_namedConstructorCall_noConstructor() { | 13637 test_unresolved_annotation_namedConstructorCall_noConstructor() { |
| 5071 checkLibrary('@String.foo() class C {}', allowErrors: true); | 13638 var library = checkLibrary('@String.foo() class C {}', allowErrors: true); |
| 13639 if (isStrongMode) { |
| 13640 checkElementText( |
| 13641 library, |
| 13642 r''' |
| 13643 @String.foo() |
| 13644 class C { |
| 13645 } |
| 13646 '''); |
| 13647 } else { |
| 13648 checkElementText( |
| 13649 library, |
| 13650 r''' |
| 13651 @String.foo() |
| 13652 class C { |
| 13653 } |
| 13654 '''); |
| 13655 } |
| 5072 } | 13656 } |
| 5073 | 13657 |
| 5074 test_unresolved_annotation_prefixedIdentifier_badPrefix() { | 13658 test_unresolved_annotation_prefixedIdentifier_badPrefix() { |
| 5075 checkLibrary('@foo.bar class C {}', allowErrors: true); | 13659 var library = checkLibrary('@foo.bar class C {}', allowErrors: true); |
| 13660 if (isStrongMode) { |
| 13661 checkElementText( |
| 13662 library, |
| 13663 r''' |
| 13664 @foo.bar |
| 13665 class C { |
| 13666 } |
| 13667 '''); |
| 13668 } else { |
| 13669 checkElementText( |
| 13670 library, |
| 13671 r''' |
| 13672 @foo.bar |
| 13673 class C { |
| 13674 } |
| 13675 '''); |
| 13676 } |
| 5076 } | 13677 } |
| 5077 | 13678 |
| 5078 test_unresolved_annotation_prefixedIdentifier_noDeclaration() { | 13679 test_unresolved_annotation_prefixedIdentifier_noDeclaration() { |
| 5079 checkLibrary('import "dart:async" as foo; @foo.bar class C {}', | 13680 var library = checkLibrary( |
| 5080 allowErrors: true); | 13681 'import "dart:async" as foo; @foo.bar class C {}', |
| 13682 allowErrors: true); |
| 13683 if (isStrongMode) { |
| 13684 checkElementText( |
| 13685 library, |
| 13686 r''' |
| 13687 import 'dart:async' as foo; |
| 13688 @foo.bar |
| 13689 class C { |
| 13690 } |
| 13691 '''); |
| 13692 } else { |
| 13693 checkElementText( |
| 13694 library, |
| 13695 r''' |
| 13696 import 'dart:async' as foo; |
| 13697 @foo.bar |
| 13698 class C { |
| 13699 } |
| 13700 '''); |
| 13701 } |
| 5081 } | 13702 } |
| 5082 | 13703 |
| 5083 test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() { | 13704 test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() { |
| 5084 checkLibrary('@foo.bar.baz() class C {}', allowErrors: true); | 13705 var library = checkLibrary('@foo.bar.baz() class C {}', allowErrors: true); |
| 13706 if (isStrongMode) { |
| 13707 checkElementText( |
| 13708 library, |
| 13709 r''' |
| 13710 @foo.bar.baz() |
| 13711 class C { |
| 13712 } |
| 13713 '''); |
| 13714 } else { |
| 13715 checkElementText( |
| 13716 library, |
| 13717 r''' |
| 13718 @foo.bar.baz() |
| 13719 class C { |
| 13720 } |
| 13721 '''); |
| 13722 } |
| 5085 } | 13723 } |
| 5086 | 13724 |
| 5087 test_unresolved_annotation_prefixedNamedConstructorCall_noClass() { | 13725 test_unresolved_annotation_prefixedNamedConstructorCall_noClass() { |
| 5088 checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}', | 13726 var library = checkLibrary( |
| 5089 allowErrors: true); | 13727 'import "dart:async" as foo; @foo.bar.baz() class C {}', |
| 13728 allowErrors: true); |
| 13729 if (isStrongMode) { |
| 13730 checkElementText( |
| 13731 library, |
| 13732 r''' |
| 13733 import 'dart:async' as foo; |
| 13734 @foo.bar.baz() |
| 13735 class C { |
| 13736 } |
| 13737 '''); |
| 13738 } else { |
| 13739 checkElementText( |
| 13740 library, |
| 13741 r''' |
| 13742 import 'dart:async' as foo; |
| 13743 @foo.bar.baz() |
| 13744 class C { |
| 13745 } |
| 13746 '''); |
| 13747 } |
| 5090 } | 13748 } |
| 5091 | 13749 |
| 5092 test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() { | 13750 test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() { |
| 5093 checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}', | 13751 var library = checkLibrary( |
| 5094 allowErrors: true); | 13752 'import "dart:async" as foo; @foo.Future.bar() class C {}', |
| 13753 allowErrors: true); |
| 13754 if (isStrongMode) { |
| 13755 checkElementText( |
| 13756 library, |
| 13757 r''' |
| 13758 import 'dart:async' as foo; |
| 13759 @foo.Future.bar() |
| 13760 class C { |
| 13761 } |
| 13762 '''); |
| 13763 } else { |
| 13764 checkElementText( |
| 13765 library, |
| 13766 r''' |
| 13767 import 'dart:async' as foo; |
| 13768 @foo.Future.bar() |
| 13769 class C { |
| 13770 } |
| 13771 '''); |
| 13772 } |
| 5095 } | 13773 } |
| 5096 | 13774 |
| 5097 test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() { | 13775 test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() { |
| 5098 checkLibrary('@foo.bar() class C {}', allowErrors: true); | 13776 var library = checkLibrary('@foo.bar() class C {}', allowErrors: true); |
| 13777 if (isStrongMode) { |
| 13778 checkElementText( |
| 13779 library, |
| 13780 r''' |
| 13781 @foo.bar() |
| 13782 class C { |
| 13783 } |
| 13784 '''); |
| 13785 } else { |
| 13786 checkElementText( |
| 13787 library, |
| 13788 r''' |
| 13789 @foo.bar() |
| 13790 class C { |
| 13791 } |
| 13792 '''); |
| 13793 } |
| 5099 } | 13794 } |
| 5100 | 13795 |
| 5101 test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() { | 13796 test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() { |
| 5102 checkLibrary('import "dart:async" as foo; @foo.bar() class C {}', | 13797 var library = checkLibrary( |
| 5103 allowErrors: true); | 13798 'import "dart:async" as foo; @foo.bar() class C {}', |
| 13799 allowErrors: true); |
| 13800 if (isStrongMode) { |
| 13801 checkElementText( |
| 13802 library, |
| 13803 r''' |
| 13804 import 'dart:async' as foo; |
| 13805 @foo.bar() |
| 13806 class C { |
| 13807 } |
| 13808 '''); |
| 13809 } else { |
| 13810 checkElementText( |
| 13811 library, |
| 13812 r''' |
| 13813 import 'dart:async' as foo; |
| 13814 @foo.bar() |
| 13815 class C { |
| 13816 } |
| 13817 '''); |
| 13818 } |
| 5104 } | 13819 } |
| 5105 | 13820 |
| 5106 test_unresolved_annotation_simpleIdentifier() { | 13821 test_unresolved_annotation_simpleIdentifier() { |
| 5107 checkLibrary('@foo class C {}', allowErrors: true); | 13822 var library = checkLibrary('@foo class C {}', allowErrors: true); |
| 13823 if (isStrongMode) { |
| 13824 checkElementText( |
| 13825 library, |
| 13826 r''' |
| 13827 @foo |
| 13828 class C { |
| 13829 } |
| 13830 '''); |
| 13831 } else { |
| 13832 checkElementText( |
| 13833 library, |
| 13834 r''' |
| 13835 @foo |
| 13836 class C { |
| 13837 } |
| 13838 '''); |
| 13839 } |
| 5108 } | 13840 } |
| 5109 | 13841 |
| 5110 test_unresolved_annotation_unnamedConstructorCall_noClass() { | 13842 test_unresolved_annotation_unnamedConstructorCall_noClass() { |
| 5111 checkLibrary('@foo() class C {}', allowErrors: true); | 13843 var library = checkLibrary('@foo() class C {}', allowErrors: true); |
| 13844 if (isStrongMode) { |
| 13845 checkElementText( |
| 13846 library, |
| 13847 r''' |
| 13848 @foo() |
| 13849 class C { |
| 13850 } |
| 13851 '''); |
| 13852 } else { |
| 13853 checkElementText( |
| 13854 library, |
| 13855 r''' |
| 13856 @foo() |
| 13857 class C { |
| 13858 } |
| 13859 '''); |
| 13860 } |
| 5112 } | 13861 } |
| 5113 | 13862 |
| 5114 test_unresolved_export() { | 13863 test_unresolved_export() { |
| 5115 allowMissingFiles = true; | 13864 allowMissingFiles = true; |
| 5116 checkLibrary("export 'foo.dart';", allowErrors: true); | 13865 var library = checkLibrary("export 'foo.dart';", allowErrors: true); |
| 13866 if (isStrongMode) { |
| 13867 checkElementText( |
| 13868 library, |
| 13869 r''' |
| 13870 export 'foo.dart'; |
| 13871 '''); |
| 13872 } else { |
| 13873 checkElementText( |
| 13874 library, |
| 13875 r''' |
| 13876 export 'foo.dart'; |
| 13877 '''); |
| 13878 } |
| 5117 } | 13879 } |
| 5118 | 13880 |
| 5119 test_unresolved_import() { | 13881 test_unresolved_import() { |
| 5120 allowMissingFiles = true; | 13882 allowMissingFiles = true; |
| 5121 LibraryElementImpl library = | 13883 LibraryElementImpl library = |
| 5122 checkLibrary("import 'foo.dart';", allowErrors: true); | 13884 checkLibrary("import 'foo.dart';", allowErrors: true); |
| 5123 LibraryElement importedLibrary = library.imports[0].importedLibrary; | 13885 LibraryElement importedLibrary = library.imports[0].importedLibrary; |
| 5124 expect(importedLibrary.loadLibraryFunction, isNotNull); | 13886 expect(importedLibrary.loadLibraryFunction, isNotNull); |
| 5125 expect(importedLibrary.publicNamespace, isNotNull); | 13887 expect(importedLibrary.publicNamespace, isNotNull); |
| 5126 expect(importedLibrary.exportNamespace, isNotNull); | 13888 expect(importedLibrary.exportNamespace, isNotNull); |
| 13889 if (isStrongMode) { |
| 13890 checkElementText( |
| 13891 library, |
| 13892 r''' |
| 13893 import 'foo.dart'; |
| 13894 '''); |
| 13895 } else { |
| 13896 checkElementText( |
| 13897 library, |
| 13898 r''' |
| 13899 import 'foo.dart'; |
| 13900 '''); |
| 13901 } |
| 5127 } | 13902 } |
| 5128 | 13903 |
| 5129 test_unresolved_part() { | 13904 test_unresolved_part() { |
| 5130 allowMissingFiles = true; | 13905 allowMissingFiles = true; |
| 5131 checkLibrary("part 'foo.dart';", allowErrors: true); | 13906 var library = checkLibrary("part 'foo.dart';", allowErrors: true); |
| 13907 if (isStrongMode) { |
| 13908 checkElementText( |
| 13909 library, |
| 13910 r''' |
| 13911 part 'foo.dart'; |
| 13912 -------------------- |
| 13913 unit: foo.dart |
| 13914 |
| 13915 '''); |
| 13916 } else { |
| 13917 checkElementText( |
| 13918 library, |
| 13919 r''' |
| 13920 part 'foo.dart'; |
| 13921 -------------------- |
| 13922 unit: foo.dart |
| 13923 |
| 13924 '''); |
| 13925 } |
| 5132 } | 13926 } |
| 5133 | 13927 |
| 5134 test_unused_type_parameter() { | 13928 test_unused_type_parameter() { |
| 5135 checkLibrary(''' | 13929 var library = checkLibrary(''' |
| 5136 class C<T> { | 13930 class C<T> { |
| 5137 void f() {} | 13931 void f() {} |
| 5138 } | 13932 } |
| 5139 C<int> c; | 13933 C<int> c; |
| 5140 var v = c.f; | 13934 var v = c.f; |
| 5141 '''); | 13935 '''); |
| 13936 if (isStrongMode) { |
| 13937 checkElementText( |
| 13938 library, |
| 13939 r''' |
| 13940 class C<T> { |
| 13941 void f() {} |
| 13942 } |
| 13943 C<int> c; |
| 13944 () → void v; |
| 13945 '''); |
| 13946 } else { |
| 13947 checkElementText( |
| 13948 library, |
| 13949 r''' |
| 13950 class C<T> { |
| 13951 void f() {} |
| 13952 } |
| 13953 C<int> c; |
| 13954 dynamic v; |
| 13955 '''); |
| 13956 } |
| 5142 } | 13957 } |
| 5143 | 13958 |
| 5144 test_variable_const() { | 13959 test_variable_const() { |
| 5145 checkLibrary('const int i = 0;'); | 13960 var library = checkLibrary('const int i = 0;'); |
| 13961 if (isStrongMode) { |
| 13962 checkElementText( |
| 13963 library, |
| 13964 r''' |
| 13965 const int i = 0; |
| 13966 '''); |
| 13967 } else { |
| 13968 checkElementText( |
| 13969 library, |
| 13970 r''' |
| 13971 const int i = 0; |
| 13972 '''); |
| 13973 } |
| 5146 } | 13974 } |
| 5147 | 13975 |
| 5148 test_variable_documented() { | 13976 test_variable_documented() { |
| 5149 checkLibrary(''' | 13977 var library = checkLibrary(''' |
| 5150 // Extra comment so doc comment offset != 0 | 13978 // Extra comment so doc comment offset != 0 |
| 5151 /** | 13979 /** |
| 5152 * Docs | 13980 * Docs |
| 5153 */ | 13981 */ |
| 5154 var x;'''); | 13982 var x;'''); |
| 13983 if (isStrongMode) { |
| 13984 checkElementText( |
| 13985 library, |
| 13986 r''' |
| 13987 /** |
| 13988 * Docs |
| 13989 */ |
| 13990 dynamic x; |
| 13991 '''); |
| 13992 } else { |
| 13993 checkElementText( |
| 13994 library, |
| 13995 r''' |
| 13996 /** |
| 13997 * Docs |
| 13998 */ |
| 13999 dynamic x; |
| 14000 '''); |
| 14001 } |
| 5155 } | 14002 } |
| 5156 | 14003 |
| 5157 test_variable_final() { | 14004 test_variable_final() { |
| 5158 checkLibrary('final int x = 0;'); | 14005 var library = checkLibrary('final int x = 0;'); |
| 14006 if (isStrongMode) { |
| 14007 checkElementText( |
| 14008 library, |
| 14009 r''' |
| 14010 final int x; |
| 14011 '''); |
| 14012 } else { |
| 14013 checkElementText( |
| 14014 library, |
| 14015 r''' |
| 14016 final int x; |
| 14017 '''); |
| 14018 } |
| 5159 } | 14019 } |
| 5160 | 14020 |
| 5161 test_variable_final_top_level_untyped() { | 14021 test_variable_final_top_level_untyped() { |
| 5162 checkLibrary('final v = 0;'); | 14022 var library = checkLibrary('final v = 0;'); |
| 14023 if (isStrongMode) { |
| 14024 checkElementText( |
| 14025 library, |
| 14026 r''' |
| 14027 final int v; |
| 14028 '''); |
| 14029 } else { |
| 14030 checkElementText( |
| 14031 library, |
| 14032 r''' |
| 14033 final dynamic v; |
| 14034 '''); |
| 14035 } |
| 5163 } | 14036 } |
| 5164 | 14037 |
| 5165 test_variable_getterInLib_setterInPart() { | 14038 test_variable_getterInLib_setterInPart() { |
| 5166 addSource('/a.dart', 'part of my.lib; void set x(int _) {}'); | 14039 addSource('/a.dart', 'part of my.lib; void set x(int _) {}'); |
| 5167 checkLibrary('library my.lib; part "a.dart"; int get x => 42;'); | 14040 var library = |
| 14041 checkLibrary('library my.lib; part "a.dart"; int get x => 42;'); |
| 14042 if (isStrongMode) { |
| 14043 checkElementText( |
| 14044 library, |
| 14045 r''' |
| 14046 library my.lib; |
| 14047 part 'a.dart'; |
| 14048 int get x {} |
| 14049 -------------------- |
| 14050 unit: a.dart |
| 14051 |
| 14052 void set x(int _) {} |
| 14053 '''); |
| 14054 } else { |
| 14055 checkElementText( |
| 14056 library, |
| 14057 r''' |
| 14058 library my.lib; |
| 14059 part 'a.dart'; |
| 14060 int get x {} |
| 14061 -------------------- |
| 14062 unit: a.dart |
| 14063 |
| 14064 void set x(int _) {} |
| 14065 '''); |
| 14066 } |
| 5168 } | 14067 } |
| 5169 | 14068 |
| 5170 test_variable_getterInPart_setterInLib() { | 14069 test_variable_getterInPart_setterInLib() { |
| 5171 addSource('/a.dart', 'part of my.lib; int get x => 42;'); | 14070 addSource('/a.dart', 'part of my.lib; int get x => 42;'); |
| 5172 checkLibrary('library my.lib; part "a.dart"; void set x(int _) {}'); | 14071 var library = |
| 14072 checkLibrary('library my.lib; part "a.dart"; void set x(int _) {}'); |
| 14073 if (isStrongMode) { |
| 14074 checkElementText( |
| 14075 library, |
| 14076 r''' |
| 14077 library my.lib; |
| 14078 part 'a.dart'; |
| 14079 void set x(int _) {} |
| 14080 -------------------- |
| 14081 unit: a.dart |
| 14082 |
| 14083 int get x {} |
| 14084 '''); |
| 14085 } else { |
| 14086 checkElementText( |
| 14087 library, |
| 14088 r''' |
| 14089 library my.lib; |
| 14090 part 'a.dart'; |
| 14091 void set x(int _) {} |
| 14092 -------------------- |
| 14093 unit: a.dart |
| 14094 |
| 14095 int get x {} |
| 14096 '''); |
| 14097 } |
| 5173 } | 14098 } |
| 5174 | 14099 |
| 5175 test_variable_getterInPart_setterInPart() { | 14100 test_variable_getterInPart_setterInPart() { |
| 5176 addSource('/a.dart', 'part of my.lib; int get x => 42;'); | 14101 addSource('/a.dart', 'part of my.lib; int get x => 42;'); |
| 5177 addSource('/b.dart', 'part of my.lib; void set x(int _) {}'); | 14102 addSource('/b.dart', 'part of my.lib; void set x(int _) {}'); |
| 5178 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 14103 var library = checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 14104 if (isStrongMode) { |
| 14105 checkElementText( |
| 14106 library, |
| 14107 r''' |
| 14108 library my.lib; |
| 14109 part 'a.dart'; |
| 14110 part 'b.dart'; |
| 14111 -------------------- |
| 14112 unit: a.dart |
| 14113 |
| 14114 int get x {} |
| 14115 -------------------- |
| 14116 unit: b.dart |
| 14117 |
| 14118 void set x(int _) {} |
| 14119 '''); |
| 14120 } else { |
| 14121 checkElementText( |
| 14122 library, |
| 14123 r''' |
| 14124 library my.lib; |
| 14125 part 'a.dart'; |
| 14126 part 'b.dart'; |
| 14127 -------------------- |
| 14128 unit: a.dart |
| 14129 |
| 14130 int get x {} |
| 14131 -------------------- |
| 14132 unit: b.dart |
| 14133 |
| 14134 void set x(int _) {} |
| 14135 '''); |
| 14136 } |
| 5179 } | 14137 } |
| 5180 | 14138 |
| 5181 test_variable_implicit_type() { | 14139 test_variable_implicit_type() { |
| 5182 checkLibrary('var x;'); | 14140 var library = checkLibrary('var x;'); |
| 14141 if (isStrongMode) { |
| 14142 checkElementText( |
| 14143 library, |
| 14144 r''' |
| 14145 dynamic x; |
| 14146 '''); |
| 14147 } else { |
| 14148 checkElementText( |
| 14149 library, |
| 14150 r''' |
| 14151 dynamic x; |
| 14152 '''); |
| 14153 } |
| 5183 } | 14154 } |
| 5184 | 14155 |
| 5185 test_variable_inferred_type_implicit_initialized() { | 14156 test_variable_inferred_type_implicit_initialized() { |
| 5186 checkLibrary('var v = 0;'); | 14157 var library = checkLibrary('var v = 0;'); |
| 14158 if (isStrongMode) { |
| 14159 checkElementText( |
| 14160 library, |
| 14161 r''' |
| 14162 int v; |
| 14163 '''); |
| 14164 } else { |
| 14165 checkElementText( |
| 14166 library, |
| 14167 r''' |
| 14168 dynamic v; |
| 14169 '''); |
| 14170 } |
| 5187 } | 14171 } |
| 5188 | 14172 |
| 5189 test_variable_propagatedType_const_noDep() { | 14173 test_variable_propagatedType_const_noDep() { |
| 5190 checkLibrary('const i = 0;'); | 14174 var library = checkLibrary('const i = 0;'); |
| 14175 if (isStrongMode) { |
| 14176 checkElementText( |
| 14177 library, |
| 14178 r''' |
| 14179 const int i = 0; |
| 14180 '''); |
| 14181 } else { |
| 14182 checkElementText( |
| 14183 library, |
| 14184 r''' |
| 14185 const dynamic i = 0; |
| 14186 '''); |
| 14187 } |
| 5191 } | 14188 } |
| 5192 | 14189 |
| 5193 test_variable_propagatedType_final_dep_inLib() { | 14190 test_variable_propagatedType_final_dep_inLib() { |
| 5194 addLibrarySource('/a.dart', 'final a = 1;'); | 14191 addLibrarySource('/a.dart', 'final a = 1;'); |
| 5195 checkLibrary('import "a.dart"; final b = a / 2;'); | 14192 var library = checkLibrary('import "a.dart"; final b = a / 2;'); |
| 14193 if (isStrongMode) { |
| 14194 checkElementText( |
| 14195 library, |
| 14196 r''' |
| 14197 import 'a.dart'; |
| 14198 final num b; |
| 14199 '''); |
| 14200 } else { |
| 14201 checkElementText( |
| 14202 library, |
| 14203 r''' |
| 14204 import 'a.dart'; |
| 14205 final dynamic b; |
| 14206 '''); |
| 14207 } |
| 5196 } | 14208 } |
| 5197 | 14209 |
| 5198 test_variable_propagatedType_final_dep_inPart() { | 14210 test_variable_propagatedType_final_dep_inPart() { |
| 5199 addSource('/a.dart', 'part of lib; final a = 1;'); | 14211 addSource('/a.dart', 'part of lib; final a = 1;'); |
| 5200 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); | 14212 var library = checkLibrary('library lib; part "a.dart"; final b = a / 2;'); |
| 14213 if (isStrongMode) { |
| 14214 checkElementText( |
| 14215 library, |
| 14216 r''' |
| 14217 library lib; |
| 14218 part 'a.dart'; |
| 14219 final num b; |
| 14220 -------------------- |
| 14221 unit: a.dart |
| 14222 |
| 14223 final int a; |
| 14224 '''); |
| 14225 } else { |
| 14226 checkElementText( |
| 14227 library, |
| 14228 r''' |
| 14229 library lib; |
| 14230 part 'a.dart'; |
| 14231 final dynamic b; |
| 14232 -------------------- |
| 14233 unit: a.dart |
| 14234 |
| 14235 final dynamic a; |
| 14236 '''); |
| 14237 } |
| 5201 } | 14238 } |
| 5202 | 14239 |
| 5203 test_variable_propagatedType_final_noDep() { | 14240 test_variable_propagatedType_final_noDep() { |
| 5204 checkLibrary('final i = 0;'); | 14241 var library = checkLibrary('final i = 0;'); |
| 14242 if (isStrongMode) { |
| 14243 checkElementText( |
| 14244 library, |
| 14245 r''' |
| 14246 final int i; |
| 14247 '''); |
| 14248 } else { |
| 14249 checkElementText( |
| 14250 library, |
| 14251 r''' |
| 14252 final dynamic i; |
| 14253 '''); |
| 14254 } |
| 5205 } | 14255 } |
| 5206 | 14256 |
| 5207 test_variable_propagatedType_implicit_dep() { | 14257 test_variable_propagatedType_implicit_dep() { |
| 5208 // The propagated type is defined in a library that is not imported. | 14258 // The propagated type is defined in a library that is not imported. |
| 5209 addLibrarySource('/a.dart', 'class C {}'); | 14259 addLibrarySource('/a.dart', 'class C {}'); |
| 5210 addLibrarySource('/b.dart', 'import "a.dart"; C f() => null;'); | 14260 addLibrarySource('/b.dart', 'import "a.dart"; C f() => null;'); |
| 5211 checkLibrary('import "b.dart"; final x = f();'); | 14261 var library = checkLibrary('import "b.dart"; final x = f();'); |
| 14262 if (isStrongMode) { |
| 14263 checkElementText( |
| 14264 library, |
| 14265 r''' |
| 14266 import 'b.dart'; |
| 14267 final C x; |
| 14268 '''); |
| 14269 } else { |
| 14270 checkElementText( |
| 14271 library, |
| 14272 r''' |
| 14273 import 'b.dart'; |
| 14274 final dynamic x; |
| 14275 '''); |
| 14276 } |
| 5212 } | 14277 } |
| 5213 | 14278 |
| 5214 test_variable_setterInPart_getterInPart() { | 14279 test_variable_setterInPart_getterInPart() { |
| 5215 addSource('/a.dart', 'part of my.lib; void set x(int _) {}'); | 14280 addSource('/a.dart', 'part of my.lib; void set x(int _) {}'); |
| 5216 addSource('/b.dart', 'part of my.lib; int get x => 42;'); | 14281 addSource('/b.dart', 'part of my.lib; int get x => 42;'); |
| 5217 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 14282 var library = checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 14283 if (isStrongMode) { |
| 14284 checkElementText( |
| 14285 library, |
| 14286 r''' |
| 14287 library my.lib; |
| 14288 part 'a.dart'; |
| 14289 part 'b.dart'; |
| 14290 -------------------- |
| 14291 unit: a.dart |
| 14292 |
| 14293 void set x(int _) {} |
| 14294 -------------------- |
| 14295 unit: b.dart |
| 14296 |
| 14297 int get x {} |
| 14298 '''); |
| 14299 } else { |
| 14300 checkElementText( |
| 14301 library, |
| 14302 r''' |
| 14303 library my.lib; |
| 14304 part 'a.dart'; |
| 14305 part 'b.dart'; |
| 14306 -------------------- |
| 14307 unit: a.dart |
| 14308 |
| 14309 void set x(int _) {} |
| 14310 -------------------- |
| 14311 unit: b.dart |
| 14312 |
| 14313 int get x {} |
| 14314 '''); |
| 14315 } |
| 5218 } | 14316 } |
| 5219 | 14317 |
| 5220 test_variables() { | 14318 test_variables() { |
| 5221 checkLibrary('int i; int j;'); | 14319 var library = checkLibrary('int i; int j;'); |
| 14320 if (isStrongMode) { |
| 14321 checkElementText( |
| 14322 library, |
| 14323 r''' |
| 14324 int i; |
| 14325 int j; |
| 14326 '''); |
| 14327 } else { |
| 14328 checkElementText( |
| 14329 library, |
| 14330 r''' |
| 14331 int i; |
| 14332 int j; |
| 14333 '''); |
| 14334 } |
| 5222 } | 14335 } |
| 5223 | 14336 |
| 5224 /** | 14337 /** |
| 5225 * Encode the library containing [original] into a summary and then use | 14338 * Encode the library containing [original] into a summary and then use |
| 5226 * [TestSummaryResynthesizer.getElement] to retrieve just the original | 14339 * [TestSummaryResynthesizer.getElement] to retrieve just the original |
| 5227 * element from the resynthesized summary. | 14340 * element from the resynthesized summary. |
| 5228 */ | 14341 */ |
| 5229 Element validateGetElement(String text, Element original) { | 14342 Element validateGetElement(String text, Element original) { |
| 5230 SummaryResynthesizer resynthesizer = | 14343 SummaryResynthesizer resynthesizer = |
| 5231 encodeDecodeLibrarySource(original.library.source); | 14344 encodeDecodeLibrarySource(original.library.source); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5284 fail('Unexpectedly tried to get unlinked summary for $uri'); | 14397 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 5285 } | 14398 } |
| 5286 return serializedUnit; | 14399 return serializedUnit; |
| 5287 } | 14400 } |
| 5288 | 14401 |
| 5289 @override | 14402 @override |
| 5290 bool hasLibrarySummary(String uri) { | 14403 bool hasLibrarySummary(String uri) { |
| 5291 return true; | 14404 return true; |
| 5292 } | 14405 } |
| 5293 } | 14406 } |
| OLD | NEW |