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 analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 /** | 172 /** |
173 * Add the given source file so that it may be referenced by the file under | 173 * Add the given source file so that it may be referenced by the file under |
174 * test. | 174 * test. |
175 */ | 175 */ |
176 Source addNamedSource(String filePath, String contents); | 176 Source addNamedSource(String filePath, String contents); |
177 | 177 |
178 /** | 178 /** |
179 * Check that [annotations] contains a single entry which is a reference to | 179 * Check that [annotations] contains a single entry which is a reference to |
180 * a top level variable called `a` in the current library. | 180 * a top level variable called `a` in the current library. |
181 */ | 181 */ |
182 void checkAnnotationA(List<UnlinkedConst> annotations) { | 182 void checkAnnotationA(List<UnlinkedExpr> annotations) { |
183 expect(annotations, hasLength(1)); | 183 expect(annotations, hasLength(1)); |
184 _assertUnlinkedConst(annotations[0], operators: [ | 184 _assertUnlinkedConst(annotations[0], operators: [ |
185 UnlinkedConstOperation.pushReference | 185 UnlinkedExprOperation.pushReference |
186 ], referenceValidators: [ | 186 ], referenceValidators: [ |
187 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 187 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
188 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 188 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
189 ]); | 189 ]); |
190 } | 190 } |
191 | 191 |
192 void checkConstCycle(String className, | 192 void checkConstCycle(String className, |
193 {String name: '', bool hasCycle: true}) { | 193 {String name: '', bool hasCycle: true}) { |
194 UnlinkedClass cls = findClass(className); | 194 UnlinkedClass cls = findClass(className); |
195 int constCycleSlot = | 195 int constCycleSlot = |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 absUri('/b.dart'), 'b.dart', 'D', | 1540 absUri('/b.dart'), 'b.dart', 'D', |
1541 onlyInStrongMode: false); | 1541 onlyInStrongMode: false); |
1542 if (!skipFullyLinkedData) { | 1542 if (!skipFullyLinkedData) { |
1543 checkHasDependency('b.dart', fullyLinked: true); | 1543 checkHasDependency('b.dart', fullyLinked: true); |
1544 } | 1544 } |
1545 } | 1545 } |
1546 | 1546 |
1547 test_constExpr_binary_add() { | 1547 test_constExpr_binary_add() { |
1548 UnlinkedVariable variable = serializeVariableText('const v = 1 + 2;'); | 1548 UnlinkedVariable variable = serializeVariableText('const v = 1 + 2;'); |
1549 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1549 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1550 UnlinkedConstOperation.pushInt, | 1550 UnlinkedExprOperation.pushInt, |
1551 UnlinkedConstOperation.pushInt, | 1551 UnlinkedExprOperation.pushInt, |
1552 UnlinkedConstOperation.add | 1552 UnlinkedExprOperation.add |
1553 ], ints: [ | 1553 ], ints: [ |
1554 1, | 1554 1, |
1555 2 | 1555 2 |
1556 ]); | 1556 ]); |
1557 } | 1557 } |
1558 | 1558 |
1559 test_constExpr_binary_and() { | 1559 test_constExpr_binary_and() { |
1560 UnlinkedVariable variable = | 1560 UnlinkedVariable variable = |
1561 serializeVariableText('const v = true && false;'); | 1561 serializeVariableText('const v = true && false;'); |
1562 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1562 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1563 UnlinkedConstOperation.pushTrue, | 1563 UnlinkedExprOperation.pushTrue, |
1564 UnlinkedConstOperation.pushFalse, | 1564 UnlinkedExprOperation.pushFalse, |
1565 UnlinkedConstOperation.and | 1565 UnlinkedExprOperation.and |
1566 ]); | 1566 ]); |
1567 } | 1567 } |
1568 | 1568 |
1569 test_constExpr_binary_bitAnd() { | 1569 test_constExpr_binary_bitAnd() { |
1570 UnlinkedVariable variable = serializeVariableText('const v = 1 & 2;'); | 1570 UnlinkedVariable variable = serializeVariableText('const v = 1 & 2;'); |
1571 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1571 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1572 UnlinkedConstOperation.pushInt, | 1572 UnlinkedExprOperation.pushInt, |
1573 UnlinkedConstOperation.pushInt, | 1573 UnlinkedExprOperation.pushInt, |
1574 UnlinkedConstOperation.bitAnd | 1574 UnlinkedExprOperation.bitAnd |
1575 ], ints: [ | 1575 ], ints: [ |
1576 1, | 1576 1, |
1577 2 | 1577 2 |
1578 ]); | 1578 ]); |
1579 } | 1579 } |
1580 | 1580 |
1581 test_constExpr_binary_bitOr() { | 1581 test_constExpr_binary_bitOr() { |
1582 UnlinkedVariable variable = serializeVariableText('const v = 1 | 2;'); | 1582 UnlinkedVariable variable = serializeVariableText('const v = 1 | 2;'); |
1583 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1583 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1584 UnlinkedConstOperation.pushInt, | 1584 UnlinkedExprOperation.pushInt, |
1585 UnlinkedConstOperation.pushInt, | 1585 UnlinkedExprOperation.pushInt, |
1586 UnlinkedConstOperation.bitOr | 1586 UnlinkedExprOperation.bitOr |
1587 ], ints: [ | 1587 ], ints: [ |
1588 1, | 1588 1, |
1589 2 | 1589 2 |
1590 ]); | 1590 ]); |
1591 } | 1591 } |
1592 | 1592 |
1593 test_constExpr_binary_bitShiftLeft() { | 1593 test_constExpr_binary_bitShiftLeft() { |
1594 UnlinkedVariable variable = serializeVariableText('const v = 1 << 2;'); | 1594 UnlinkedVariable variable = serializeVariableText('const v = 1 << 2;'); |
1595 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1595 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1596 UnlinkedConstOperation.pushInt, | 1596 UnlinkedExprOperation.pushInt, |
1597 UnlinkedConstOperation.pushInt, | 1597 UnlinkedExprOperation.pushInt, |
1598 UnlinkedConstOperation.bitShiftLeft | 1598 UnlinkedExprOperation.bitShiftLeft |
1599 ], ints: [ | 1599 ], ints: [ |
1600 1, | 1600 1, |
1601 2 | 1601 2 |
1602 ]); | 1602 ]); |
1603 } | 1603 } |
1604 | 1604 |
1605 test_constExpr_binary_bitShiftRight() { | 1605 test_constExpr_binary_bitShiftRight() { |
1606 UnlinkedVariable variable = serializeVariableText('const v = 1 >> 2;'); | 1606 UnlinkedVariable variable = serializeVariableText('const v = 1 >> 2;'); |
1607 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1607 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1608 UnlinkedConstOperation.pushInt, | 1608 UnlinkedExprOperation.pushInt, |
1609 UnlinkedConstOperation.pushInt, | 1609 UnlinkedExprOperation.pushInt, |
1610 UnlinkedConstOperation.bitShiftRight | 1610 UnlinkedExprOperation.bitShiftRight |
1611 ], ints: [ | 1611 ], ints: [ |
1612 1, | 1612 1, |
1613 2 | 1613 2 |
1614 ]); | 1614 ]); |
1615 } | 1615 } |
1616 | 1616 |
1617 test_constExpr_binary_bitXor() { | 1617 test_constExpr_binary_bitXor() { |
1618 UnlinkedVariable variable = serializeVariableText('const v = 1 ^ 2;'); | 1618 UnlinkedVariable variable = serializeVariableText('const v = 1 ^ 2;'); |
1619 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1619 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1620 UnlinkedConstOperation.pushInt, | 1620 UnlinkedExprOperation.pushInt, |
1621 UnlinkedConstOperation.pushInt, | 1621 UnlinkedExprOperation.pushInt, |
1622 UnlinkedConstOperation.bitXor | 1622 UnlinkedExprOperation.bitXor |
1623 ], ints: [ | 1623 ], ints: [ |
1624 1, | 1624 1, |
1625 2 | 1625 2 |
1626 ]); | 1626 ]); |
1627 } | 1627 } |
1628 | 1628 |
1629 test_constExpr_binary_divide() { | 1629 test_constExpr_binary_divide() { |
1630 UnlinkedVariable variable = serializeVariableText('const v = 1 / 2;'); | 1630 UnlinkedVariable variable = serializeVariableText('const v = 1 / 2;'); |
1631 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1631 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1632 UnlinkedConstOperation.pushInt, | 1632 UnlinkedExprOperation.pushInt, |
1633 UnlinkedConstOperation.pushInt, | 1633 UnlinkedExprOperation.pushInt, |
1634 UnlinkedConstOperation.divide | 1634 UnlinkedExprOperation.divide |
1635 ], ints: [ | 1635 ], ints: [ |
1636 1, | 1636 1, |
1637 2 | 1637 2 |
1638 ]); | 1638 ]); |
1639 } | 1639 } |
1640 | 1640 |
1641 test_constExpr_binary_equal() { | 1641 test_constExpr_binary_equal() { |
1642 UnlinkedVariable variable = serializeVariableText('const v = 1 == 2;'); | 1642 UnlinkedVariable variable = serializeVariableText('const v = 1 == 2;'); |
1643 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1643 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1644 UnlinkedConstOperation.pushInt, | 1644 UnlinkedExprOperation.pushInt, |
1645 UnlinkedConstOperation.pushInt, | 1645 UnlinkedExprOperation.pushInt, |
1646 UnlinkedConstOperation.equal | 1646 UnlinkedExprOperation.equal |
1647 ], ints: [ | 1647 ], ints: [ |
1648 1, | 1648 1, |
1649 2 | 1649 2 |
1650 ]); | 1650 ]); |
1651 } | 1651 } |
1652 | 1652 |
1653 test_constExpr_binary_equal_not() { | 1653 test_constExpr_binary_equal_not() { |
1654 UnlinkedVariable variable = serializeVariableText('const v = 1 != 2;'); | 1654 UnlinkedVariable variable = serializeVariableText('const v = 1 != 2;'); |
1655 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1655 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1656 UnlinkedConstOperation.pushInt, | 1656 UnlinkedExprOperation.pushInt, |
1657 UnlinkedConstOperation.pushInt, | 1657 UnlinkedExprOperation.pushInt, |
1658 UnlinkedConstOperation.notEqual | 1658 UnlinkedExprOperation.notEqual |
1659 ], ints: [ | 1659 ], ints: [ |
1660 1, | 1660 1, |
1661 2 | 1661 2 |
1662 ]); | 1662 ]); |
1663 } | 1663 } |
1664 | 1664 |
1665 test_constExpr_binary_floorDivide() { | 1665 test_constExpr_binary_floorDivide() { |
1666 UnlinkedVariable variable = serializeVariableText('const v = 1 ~/ 2;'); | 1666 UnlinkedVariable variable = serializeVariableText('const v = 1 ~/ 2;'); |
1667 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1667 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1668 UnlinkedConstOperation.pushInt, | 1668 UnlinkedExprOperation.pushInt, |
1669 UnlinkedConstOperation.pushInt, | 1669 UnlinkedExprOperation.pushInt, |
1670 UnlinkedConstOperation.floorDivide | 1670 UnlinkedExprOperation.floorDivide |
1671 ], ints: [ | 1671 ], ints: [ |
1672 1, | 1672 1, |
1673 2 | 1673 2 |
1674 ]); | 1674 ]); |
1675 } | 1675 } |
1676 | 1676 |
1677 test_constExpr_binary_greater() { | 1677 test_constExpr_binary_greater() { |
1678 UnlinkedVariable variable = serializeVariableText('const v = 1 > 2;'); | 1678 UnlinkedVariable variable = serializeVariableText('const v = 1 > 2;'); |
1679 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1679 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1680 UnlinkedConstOperation.pushInt, | 1680 UnlinkedExprOperation.pushInt, |
1681 UnlinkedConstOperation.pushInt, | 1681 UnlinkedExprOperation.pushInt, |
1682 UnlinkedConstOperation.greater | 1682 UnlinkedExprOperation.greater |
1683 ], ints: [ | 1683 ], ints: [ |
1684 1, | 1684 1, |
1685 2 | 1685 2 |
1686 ]); | 1686 ]); |
1687 } | 1687 } |
1688 | 1688 |
1689 test_constExpr_binary_greaterEqual() { | 1689 test_constExpr_binary_greaterEqual() { |
1690 UnlinkedVariable variable = serializeVariableText('const v = 1 >= 2;'); | 1690 UnlinkedVariable variable = serializeVariableText('const v = 1 >= 2;'); |
1691 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1691 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1692 UnlinkedConstOperation.pushInt, | 1692 UnlinkedExprOperation.pushInt, |
1693 UnlinkedConstOperation.pushInt, | 1693 UnlinkedExprOperation.pushInt, |
1694 UnlinkedConstOperation.greaterEqual | 1694 UnlinkedExprOperation.greaterEqual |
1695 ], ints: [ | 1695 ], ints: [ |
1696 1, | 1696 1, |
1697 2 | 1697 2 |
1698 ]); | 1698 ]); |
1699 } | 1699 } |
1700 | 1700 |
1701 test_constExpr_binary_less() { | 1701 test_constExpr_binary_less() { |
1702 UnlinkedVariable variable = serializeVariableText('const v = 1 < 2;'); | 1702 UnlinkedVariable variable = serializeVariableText('const v = 1 < 2;'); |
1703 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1703 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1704 UnlinkedConstOperation.pushInt, | 1704 UnlinkedExprOperation.pushInt, |
1705 UnlinkedConstOperation.pushInt, | 1705 UnlinkedExprOperation.pushInt, |
1706 UnlinkedConstOperation.less | 1706 UnlinkedExprOperation.less |
1707 ], ints: [ | 1707 ], ints: [ |
1708 1, | 1708 1, |
1709 2 | 1709 2 |
1710 ]); | 1710 ]); |
1711 } | 1711 } |
1712 | 1712 |
1713 test_constExpr_binary_lessEqual() { | 1713 test_constExpr_binary_lessEqual() { |
1714 UnlinkedVariable variable = serializeVariableText('const v = 1 <= 2;'); | 1714 UnlinkedVariable variable = serializeVariableText('const v = 1 <= 2;'); |
1715 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1715 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1716 UnlinkedConstOperation.pushInt, | 1716 UnlinkedExprOperation.pushInt, |
1717 UnlinkedConstOperation.pushInt, | 1717 UnlinkedExprOperation.pushInt, |
1718 UnlinkedConstOperation.lessEqual | 1718 UnlinkedExprOperation.lessEqual |
1719 ], ints: [ | 1719 ], ints: [ |
1720 1, | 1720 1, |
1721 2 | 1721 2 |
1722 ]); | 1722 ]); |
1723 } | 1723 } |
1724 | 1724 |
1725 test_constExpr_binary_modulo() { | 1725 test_constExpr_binary_modulo() { |
1726 UnlinkedVariable variable = serializeVariableText('const v = 1 % 2;'); | 1726 UnlinkedVariable variable = serializeVariableText('const v = 1 % 2;'); |
1727 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1727 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1728 UnlinkedConstOperation.pushInt, | 1728 UnlinkedExprOperation.pushInt, |
1729 UnlinkedConstOperation.pushInt, | 1729 UnlinkedExprOperation.pushInt, |
1730 UnlinkedConstOperation.modulo | 1730 UnlinkedExprOperation.modulo |
1731 ], ints: [ | 1731 ], ints: [ |
1732 1, | 1732 1, |
1733 2 | 1733 2 |
1734 ]); | 1734 ]); |
1735 } | 1735 } |
1736 | 1736 |
1737 test_constExpr_binary_multiply() { | 1737 test_constExpr_binary_multiply() { |
1738 UnlinkedVariable variable = serializeVariableText('const v = 1 * 2;'); | 1738 UnlinkedVariable variable = serializeVariableText('const v = 1 * 2;'); |
1739 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1739 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1740 UnlinkedConstOperation.pushInt, | 1740 UnlinkedExprOperation.pushInt, |
1741 UnlinkedConstOperation.pushInt, | 1741 UnlinkedExprOperation.pushInt, |
1742 UnlinkedConstOperation.multiply | 1742 UnlinkedExprOperation.multiply |
1743 ], ints: [ | 1743 ], ints: [ |
1744 1, | 1744 1, |
1745 2 | 1745 2 |
1746 ]); | 1746 ]); |
1747 } | 1747 } |
1748 | 1748 |
1749 test_constExpr_binary_or() { | 1749 test_constExpr_binary_or() { |
1750 UnlinkedVariable variable = | 1750 UnlinkedVariable variable = |
1751 serializeVariableText('const v = false || true;'); | 1751 serializeVariableText('const v = false || true;'); |
1752 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1752 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1753 UnlinkedConstOperation.pushFalse, | 1753 UnlinkedExprOperation.pushFalse, |
1754 UnlinkedConstOperation.pushTrue, | 1754 UnlinkedExprOperation.pushTrue, |
1755 UnlinkedConstOperation.or | 1755 UnlinkedExprOperation.or |
1756 ]); | 1756 ]); |
1757 } | 1757 } |
1758 | 1758 |
1759 test_constExpr_binary_subtract() { | 1759 test_constExpr_binary_subtract() { |
1760 UnlinkedVariable variable = serializeVariableText('const v = 1 - 2;'); | 1760 UnlinkedVariable variable = serializeVariableText('const v = 1 - 2;'); |
1761 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1761 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1762 UnlinkedConstOperation.pushInt, | 1762 UnlinkedExprOperation.pushInt, |
1763 UnlinkedConstOperation.pushInt, | 1763 UnlinkedExprOperation.pushInt, |
1764 UnlinkedConstOperation.subtract | 1764 UnlinkedExprOperation.subtract |
1765 ], ints: [ | 1765 ], ints: [ |
1766 1, | 1766 1, |
1767 2 | 1767 2 |
1768 ]); | 1768 ]); |
1769 } | 1769 } |
1770 | 1770 |
1771 test_constExpr_classMember_shadows_typeParam() { | 1771 test_constExpr_classMember_shadows_typeParam() { |
1772 // Although it is an error for a class member to have the same name as a | 1772 // Although it is an error for a class member to have the same name as a |
1773 // type parameter, the spec makes it clear that the class member scope is | 1773 // type parameter, the spec makes it clear that the class member scope is |
1774 // nested inside the type parameter scope. So go ahead and verify that | 1774 // nested inside the type parameter scope. So go ahead and verify that |
1775 // the class member shadows the type parameter. | 1775 // the class member shadows the type parameter. |
1776 String text = ''' | 1776 String text = ''' |
1777 class C<T> { | 1777 class C<T> { |
1778 static const T = null; | 1778 static const T = null; |
1779 final x; | 1779 final x; |
1780 const C() : x = T; | 1780 const C() : x = T; |
1781 } | 1781 } |
1782 '''; | 1782 '''; |
1783 UnlinkedClass cls = serializeClassText(text, allowErrors: true); | 1783 UnlinkedClass cls = serializeClassText(text, allowErrors: true); |
1784 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, | 1784 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, |
1785 operators: [ | 1785 operators: [ |
1786 UnlinkedConstOperation.pushReference | 1786 UnlinkedExprOperation.pushReference |
1787 ], | 1787 ], |
1788 referenceValidators: [ | 1788 referenceValidators: [ |
1789 (EntityRef r) => checkTypeRef(r, null, null, 'T', | 1789 (EntityRef r) => checkTypeRef(r, null, null, 'T', |
1790 expectedKind: ReferenceKind.propertyAccessor, | 1790 expectedKind: ReferenceKind.propertyAccessor, |
1791 prefixExpectations: [ | 1791 prefixExpectations: [ |
1792 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1792 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1793 numTypeParameters: 1) | 1793 numTypeParameters: 1) |
1794 ]) | 1794 ]) |
1795 ]); | 1795 ]); |
1796 } | 1796 } |
1797 | 1797 |
1798 test_constExpr_conditional() { | 1798 test_constExpr_conditional() { |
1799 UnlinkedVariable variable = | 1799 UnlinkedVariable variable = |
1800 serializeVariableText('const v = true ? 1 : 2;', allowErrors: true); | 1800 serializeVariableText('const v = true ? 1 : 2;', allowErrors: true); |
1801 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1801 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1802 UnlinkedConstOperation.pushTrue, | 1802 UnlinkedExprOperation.pushTrue, |
1803 UnlinkedConstOperation.pushInt, | 1803 UnlinkedExprOperation.pushInt, |
1804 UnlinkedConstOperation.pushInt, | 1804 UnlinkedExprOperation.pushInt, |
1805 UnlinkedConstOperation.conditional | 1805 UnlinkedExprOperation.conditional |
1806 ], ints: [ | 1806 ], ints: [ |
1807 1, | 1807 1, |
1808 2 | 1808 2 |
1809 ]); | 1809 ]); |
1810 } | 1810 } |
1811 | 1811 |
1812 test_constExpr_constructorParam_shadows_classMember() { | 1812 test_constExpr_constructorParam_shadows_classMember() { |
1813 UnlinkedClass cls = serializeClassText(''' | 1813 UnlinkedClass cls = serializeClassText(''' |
1814 class C { | 1814 class C { |
1815 static const a = null; | 1815 static const a = null; |
1816 final b; | 1816 final b; |
1817 const C(a) : b = a; | 1817 const C(a) : b = a; |
1818 } | 1818 } |
1819 '''); | 1819 '''); |
1820 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, | 1820 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, |
1821 operators: [UnlinkedConstOperation.pushParameter], strings: ['a']); | 1821 operators: [UnlinkedExprOperation.pushParameter], strings: ['a']); |
1822 } | 1822 } |
1823 | 1823 |
1824 test_constExpr_constructorParam_shadows_typeParam() { | 1824 test_constExpr_constructorParam_shadows_typeParam() { |
1825 UnlinkedClass cls = serializeClassText(''' | 1825 UnlinkedClass cls = serializeClassText(''' |
1826 class C<T> { | 1826 class C<T> { |
1827 final x; | 1827 final x; |
1828 const C(T) : x = T; | 1828 const C(T) : x = T; |
1829 } | 1829 } |
1830 '''); | 1830 '''); |
1831 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, | 1831 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, |
1832 operators: [UnlinkedConstOperation.pushParameter], strings: ['T']); | 1832 operators: [UnlinkedExprOperation.pushParameter], strings: ['T']); |
1833 } | 1833 } |
1834 | 1834 |
1835 test_constExpr_functionExpression_asArgument() { | 1835 test_constExpr_functionExpression_asArgument() { |
1836 // Even though function expressions are not allowed in constant | 1836 // Even though function expressions are not allowed in constant |
1837 // declarations, they might occur due to erroneous code, so make sure they | 1837 // declarations, they might occur due to erroneous code, so make sure they |
1838 // function correctly. | 1838 // function correctly. |
1839 UnlinkedVariable variable = serializeVariableText(''' | 1839 UnlinkedVariable variable = serializeVariableText(''' |
1840 const v = foo(5, () => 42); | 1840 const v = foo(5, () => 42); |
1841 foo(a, b) {} | 1841 foo(a, b) {} |
1842 '''); | 1842 '''); |
1843 _assertUnlinkedConst(variable.initializer.bodyExpr, | 1843 _assertUnlinkedConst(variable.initializer.bodyExpr, |
1844 isValidConst: false, | 1844 isValidConst: false, |
1845 operators: [ | 1845 operators: [ |
1846 UnlinkedConstOperation.pushInt, | 1846 UnlinkedExprOperation.pushInt, |
1847 UnlinkedConstOperation.pushLocalFunctionReference, | 1847 UnlinkedExprOperation.pushLocalFunctionReference, |
1848 UnlinkedConstOperation.invokeMethodRef | 1848 UnlinkedExprOperation.invokeMethodRef |
1849 ], | 1849 ], |
1850 ints: [ | 1850 ints: [ |
1851 5, | 1851 5, |
1852 0, | 1852 0, |
1853 0, | 1853 0, |
1854 0, | 1854 0, |
1855 2, | 1855 2, |
1856 0 | 1856 0 |
1857 ], | 1857 ], |
1858 referenceValidators: [ | 1858 referenceValidators: [ |
1859 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 1859 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
1860 expectedKind: ReferenceKind.topLevelFunction) | 1860 expectedKind: ReferenceKind.topLevelFunction) |
1861 ]); | 1861 ]); |
1862 } | 1862 } |
1863 | 1863 |
1864 test_constExpr_functionExpression_asArgument_multiple() { | 1864 test_constExpr_functionExpression_asArgument_multiple() { |
1865 // Even though function expressions are not allowed in constant | 1865 // Even though function expressions are not allowed in constant |
1866 // declarations, they might occur due to erroneous code, so make sure they | 1866 // declarations, they might occur due to erroneous code, so make sure they |
1867 // function correctly. | 1867 // function correctly. |
1868 UnlinkedVariable variable = serializeVariableText(''' | 1868 UnlinkedVariable variable = serializeVariableText(''' |
1869 const v = foo(5, () => 42, () => 43); | 1869 const v = foo(5, () => 42, () => 43); |
1870 foo(a, b, c) {} | 1870 foo(a, b, c) {} |
1871 '''); | 1871 '''); |
1872 _assertUnlinkedConst(variable.initializer.bodyExpr, | 1872 _assertUnlinkedConst(variable.initializer.bodyExpr, |
1873 isValidConst: false, | 1873 isValidConst: false, |
1874 operators: [ | 1874 operators: [ |
1875 UnlinkedConstOperation.pushInt, | 1875 UnlinkedExprOperation.pushInt, |
1876 UnlinkedConstOperation.pushLocalFunctionReference, | 1876 UnlinkedExprOperation.pushLocalFunctionReference, |
1877 UnlinkedConstOperation.pushLocalFunctionReference, | 1877 UnlinkedExprOperation.pushLocalFunctionReference, |
1878 UnlinkedConstOperation.invokeMethodRef | 1878 UnlinkedExprOperation.invokeMethodRef |
1879 ], | 1879 ], |
1880 ints: [ | 1880 ints: [ |
1881 5, | 1881 5, |
1882 0, | 1882 0, |
1883 0, | 1883 0, |
1884 0, | 1884 0, |
1885 1, | 1885 1, |
1886 0, | 1886 0, |
1887 3, | 1887 3, |
1888 0 | 1888 0 |
(...skipping 10 matching lines...) Expand all Loading... |
1899 // function correctly. | 1899 // function correctly. |
1900 UnlinkedExecutable executable = serializeClassText(''' | 1900 UnlinkedExecutable executable = serializeClassText(''' |
1901 class C { | 1901 class C { |
1902 final x, y; | 1902 final x, y; |
1903 const C() : x = (() => 42), y = (() => 43); | 1903 const C() : x = (() => 42), y = (() => 43); |
1904 } | 1904 } |
1905 ''').executables[0]; | 1905 ''').executables[0]; |
1906 expect(executable.localFunctions, hasLength(2)); | 1906 expect(executable.localFunctions, hasLength(2)); |
1907 _assertUnlinkedConst(executable.constantInitializers[0].expression, | 1907 _assertUnlinkedConst(executable.constantInitializers[0].expression, |
1908 isValidConst: false, | 1908 isValidConst: false, |
1909 operators: [UnlinkedConstOperation.pushLocalFunctionReference], | 1909 operators: [UnlinkedExprOperation.pushLocalFunctionReference], |
1910 ints: [0, 0]); | 1910 ints: [0, 0]); |
1911 _assertUnlinkedConst(executable.constantInitializers[1].expression, | 1911 _assertUnlinkedConst(executable.constantInitializers[1].expression, |
1912 isValidConst: false, | 1912 isValidConst: false, |
1913 operators: [UnlinkedConstOperation.pushLocalFunctionReference], | 1913 operators: [UnlinkedExprOperation.pushLocalFunctionReference], |
1914 ints: [0, 1]); | 1914 ints: [0, 1]); |
1915 } | 1915 } |
1916 | 1916 |
1917 test_constExpr_invokeConstructor_generic_named() { | 1917 test_constExpr_invokeConstructor_generic_named() { |
1918 UnlinkedVariable variable = serializeVariableText(''' | 1918 UnlinkedVariable variable = serializeVariableText(''' |
1919 class C<K, V> { | 1919 class C<K, V> { |
1920 const C.named(); | 1920 const C.named(); |
1921 } | 1921 } |
1922 const v = const C<int, String>.named(); | 1922 const v = const C<int, String>.named(); |
1923 '''); | 1923 '''); |
1924 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1924 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1925 UnlinkedConstOperation.invokeConstructor, | 1925 UnlinkedExprOperation.invokeConstructor, |
1926 ], ints: [ | 1926 ], ints: [ |
1927 0, | 1927 0, |
1928 0 | 1928 0 |
1929 ], referenceValidators: [ | 1929 ], referenceValidators: [ |
1930 (EntityRef r) { | 1930 (EntityRef r) { |
1931 checkTypeRef(r, null, null, 'named', | 1931 checkTypeRef(r, null, null, 'named', |
1932 expectedKind: ReferenceKind.constructor, | 1932 expectedKind: ReferenceKind.constructor, |
1933 prefixExpectations: [ | 1933 prefixExpectations: [ |
1934 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1934 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1935 numTypeParameters: 2) | 1935 numTypeParameters: 2) |
(...skipping 11 matching lines...) Expand all Loading... |
1947 ''' | 1947 ''' |
1948 class C<K, V> { | 1948 class C<K, V> { |
1949 const C.named(); | 1949 const C.named(); |
1950 } | 1950 } |
1951 '''); | 1951 '''); |
1952 UnlinkedVariable variable = serializeVariableText(''' | 1952 UnlinkedVariable variable = serializeVariableText(''' |
1953 import 'a.dart'; | 1953 import 'a.dart'; |
1954 const v = const C<int, String>.named(); | 1954 const v = const C<int, String>.named(); |
1955 '''); | 1955 '''); |
1956 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1956 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1957 UnlinkedConstOperation.invokeConstructor, | 1957 UnlinkedExprOperation.invokeConstructor, |
1958 ], ints: [ | 1958 ], ints: [ |
1959 0, | 1959 0, |
1960 0 | 1960 0 |
1961 ], referenceValidators: [ | 1961 ], referenceValidators: [ |
1962 (EntityRef r) { | 1962 (EntityRef r) { |
1963 checkTypeRef(r, null, null, 'named', | 1963 checkTypeRef(r, null, null, 'named', |
1964 expectedKind: ReferenceKind.constructor, | 1964 expectedKind: ReferenceKind.constructor, |
1965 prefixExpectations: [ | 1965 prefixExpectations: [ |
1966 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1966 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1967 absoluteUri: absUri('/a.dart'), | 1967 absoluteUri: absUri('/a.dart'), |
(...skipping 13 matching lines...) Expand all Loading... |
1981 ''' | 1981 ''' |
1982 class C<K, V> { | 1982 class C<K, V> { |
1983 const C.named(); | 1983 const C.named(); |
1984 } | 1984 } |
1985 '''); | 1985 '''); |
1986 UnlinkedVariable variable = serializeVariableText(''' | 1986 UnlinkedVariable variable = serializeVariableText(''' |
1987 import 'a.dart' as p; | 1987 import 'a.dart' as p; |
1988 const v = const p.C<int, String>.named(); | 1988 const v = const p.C<int, String>.named(); |
1989 '''); | 1989 '''); |
1990 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1990 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
1991 UnlinkedConstOperation.invokeConstructor, | 1991 UnlinkedExprOperation.invokeConstructor, |
1992 ], ints: [ | 1992 ], ints: [ |
1993 0, | 1993 0, |
1994 0 | 1994 0 |
1995 ], referenceValidators: [ | 1995 ], referenceValidators: [ |
1996 (EntityRef r) { | 1996 (EntityRef r) { |
1997 checkTypeRef(r, null, null, 'named', | 1997 checkTypeRef(r, null, null, 'named', |
1998 expectedKind: ReferenceKind.constructor, | 1998 expectedKind: ReferenceKind.constructor, |
1999 prefixExpectations: [ | 1999 prefixExpectations: [ |
2000 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2000 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2001 absoluteUri: absUri('/a.dart'), | 2001 absoluteUri: absUri('/a.dart'), |
2002 relativeUri: 'a.dart', | 2002 relativeUri: 'a.dart', |
2003 numTypeParameters: 2), | 2003 numTypeParameters: 2), |
2004 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2004 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2005 ], | 2005 ], |
2006 numTypeArguments: 2); | 2006 numTypeArguments: 2); |
2007 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2007 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
2008 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2008 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
2009 } | 2009 } |
2010 ]); | 2010 ]); |
2011 } | 2011 } |
2012 | 2012 |
2013 test_constExpr_invokeConstructor_generic_unnamed() { | 2013 test_constExpr_invokeConstructor_generic_unnamed() { |
2014 UnlinkedVariable variable = serializeVariableText(''' | 2014 UnlinkedVariable variable = serializeVariableText(''' |
2015 class C<K, V> { | 2015 class C<K, V> { |
2016 const C(); | 2016 const C(); |
2017 } | 2017 } |
2018 const v = const C<int, String>(); | 2018 const v = const C<int, String>(); |
2019 '''); | 2019 '''); |
2020 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2020 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2021 UnlinkedConstOperation.invokeConstructor, | 2021 UnlinkedExprOperation.invokeConstructor, |
2022 ], ints: [ | 2022 ], ints: [ |
2023 0, | 2023 0, |
2024 0 | 2024 0 |
2025 ], referenceValidators: [ | 2025 ], referenceValidators: [ |
2026 (EntityRef r) { | 2026 (EntityRef r) { |
2027 checkTypeRef(r, null, null, 'C', | 2027 checkTypeRef(r, null, null, 'C', |
2028 expectedKind: ReferenceKind.classOrEnum, | 2028 expectedKind: ReferenceKind.classOrEnum, |
2029 numTypeParameters: 2, | 2029 numTypeParameters: 2, |
2030 numTypeArguments: 2); | 2030 numTypeArguments: 2); |
2031 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2031 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
2032 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2032 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
2033 } | 2033 } |
2034 ]); | 2034 ]); |
2035 } | 2035 } |
2036 | 2036 |
2037 test_constExpr_invokeConstructor_generic_unnamed_imported() { | 2037 test_constExpr_invokeConstructor_generic_unnamed_imported() { |
2038 addNamedSource( | 2038 addNamedSource( |
2039 '/a.dart', | 2039 '/a.dart', |
2040 ''' | 2040 ''' |
2041 class C<K, V> { | 2041 class C<K, V> { |
2042 const C(); | 2042 const C(); |
2043 } | 2043 } |
2044 '''); | 2044 '''); |
2045 UnlinkedVariable variable = serializeVariableText(''' | 2045 UnlinkedVariable variable = serializeVariableText(''' |
2046 import 'a.dart'; | 2046 import 'a.dart'; |
2047 const v = const C<int, String>(); | 2047 const v = const C<int, String>(); |
2048 '''); | 2048 '''); |
2049 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2049 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2050 UnlinkedConstOperation.invokeConstructor, | 2050 UnlinkedExprOperation.invokeConstructor, |
2051 ], ints: [ | 2051 ], ints: [ |
2052 0, | 2052 0, |
2053 0 | 2053 0 |
2054 ], referenceValidators: [ | 2054 ], referenceValidators: [ |
2055 (EntityRef r) { | 2055 (EntityRef r) { |
2056 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2056 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
2057 expectedKind: ReferenceKind.classOrEnum, | 2057 expectedKind: ReferenceKind.classOrEnum, |
2058 numTypeParameters: 2, | 2058 numTypeParameters: 2, |
2059 numTypeArguments: 2); | 2059 numTypeArguments: 2); |
2060 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2060 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
2061 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2061 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
2062 } | 2062 } |
2063 ]); | 2063 ]); |
2064 } | 2064 } |
2065 | 2065 |
2066 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { | 2066 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { |
2067 addNamedSource( | 2067 addNamedSource( |
2068 '/a.dart', | 2068 '/a.dart', |
2069 ''' | 2069 ''' |
2070 class C<K, V> { | 2070 class C<K, V> { |
2071 const C(); | 2071 const C(); |
2072 } | 2072 } |
2073 '''); | 2073 '''); |
2074 UnlinkedVariable variable = serializeVariableText(''' | 2074 UnlinkedVariable variable = serializeVariableText(''' |
2075 import 'a.dart' as p; | 2075 import 'a.dart' as p; |
2076 const v = const p.C<int, String>(); | 2076 const v = const p.C<int, String>(); |
2077 '''); | 2077 '''); |
2078 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2078 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2079 UnlinkedConstOperation.invokeConstructor, | 2079 UnlinkedExprOperation.invokeConstructor, |
2080 ], ints: [ | 2080 ], ints: [ |
2081 0, | 2081 0, |
2082 0 | 2082 0 |
2083 ], referenceValidators: [ | 2083 ], referenceValidators: [ |
2084 (EntityRef r) { | 2084 (EntityRef r) { |
2085 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2085 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
2086 expectedKind: ReferenceKind.classOrEnum, | 2086 expectedKind: ReferenceKind.classOrEnum, |
2087 numTypeParameters: 2, | 2087 numTypeParameters: 2, |
2088 numTypeArguments: 2, | 2088 numTypeArguments: 2, |
2089 prefixExpectations: [ | 2089 prefixExpectations: [ |
2090 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2090 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2091 ]); | 2091 ]); |
2092 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2092 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
2093 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2093 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
2094 } | 2094 } |
2095 ]); | 2095 ]); |
2096 } | 2096 } |
2097 | 2097 |
2098 test_constExpr_invokeConstructor_named() { | 2098 test_constExpr_invokeConstructor_named() { |
2099 UnlinkedVariable variable = serializeVariableText(''' | 2099 UnlinkedVariable variable = serializeVariableText(''' |
2100 class C { | 2100 class C { |
2101 const C.named(); | 2101 const C.named(); |
2102 } | 2102 } |
2103 const v = const C.named(); | 2103 const v = const C.named(); |
2104 '''); | 2104 '''); |
2105 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2105 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2106 UnlinkedConstOperation.invokeConstructor, | 2106 UnlinkedExprOperation.invokeConstructor, |
2107 ], ints: [ | 2107 ], ints: [ |
2108 0, | 2108 0, |
2109 0 | 2109 0 |
2110 ], referenceValidators: [ | 2110 ], referenceValidators: [ |
2111 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2111 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
2112 expectedKind: ReferenceKind.constructor, | 2112 expectedKind: ReferenceKind.constructor, |
2113 prefixExpectations: [ | 2113 prefixExpectations: [ |
2114 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2114 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2115 ]) | 2115 ]) |
2116 ]); | 2116 ]); |
2117 } | 2117 } |
2118 | 2118 |
2119 test_constExpr_invokeConstructor_named_imported() { | 2119 test_constExpr_invokeConstructor_named_imported() { |
2120 addNamedSource( | 2120 addNamedSource( |
2121 '/a.dart', | 2121 '/a.dart', |
2122 ''' | 2122 ''' |
2123 class C { | 2123 class C { |
2124 const C.named(); | 2124 const C.named(); |
2125 } | 2125 } |
2126 '''); | 2126 '''); |
2127 UnlinkedVariable variable = serializeVariableText(''' | 2127 UnlinkedVariable variable = serializeVariableText(''' |
2128 import 'a.dart'; | 2128 import 'a.dart'; |
2129 const v = const C.named(); | 2129 const v = const C.named(); |
2130 '''); | 2130 '''); |
2131 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2131 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2132 UnlinkedConstOperation.invokeConstructor, | 2132 UnlinkedExprOperation.invokeConstructor, |
2133 ], ints: [ | 2133 ], ints: [ |
2134 0, | 2134 0, |
2135 0 | 2135 0 |
2136 ], referenceValidators: [ | 2136 ], referenceValidators: [ |
2137 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2137 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
2138 expectedKind: ReferenceKind.constructor, | 2138 expectedKind: ReferenceKind.constructor, |
2139 prefixExpectations: [ | 2139 prefixExpectations: [ |
2140 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2140 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2141 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2141 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
2142 ]) | 2142 ]) |
2143 ]); | 2143 ]); |
2144 } | 2144 } |
2145 | 2145 |
2146 test_constExpr_invokeConstructor_named_imported_withPrefix() { | 2146 test_constExpr_invokeConstructor_named_imported_withPrefix() { |
2147 addNamedSource( | 2147 addNamedSource( |
2148 '/a.dart', | 2148 '/a.dart', |
2149 ''' | 2149 ''' |
2150 class C { | 2150 class C { |
2151 const C.named(); | 2151 const C.named(); |
2152 } | 2152 } |
2153 '''); | 2153 '''); |
2154 UnlinkedVariable variable = serializeVariableText(''' | 2154 UnlinkedVariable variable = serializeVariableText(''' |
2155 import 'a.dart' as p; | 2155 import 'a.dart' as p; |
2156 const v = const p.C.named(); | 2156 const v = const p.C.named(); |
2157 '''); | 2157 '''); |
2158 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2158 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2159 UnlinkedConstOperation.invokeConstructor, | 2159 UnlinkedExprOperation.invokeConstructor, |
2160 ], ints: [ | 2160 ], ints: [ |
2161 0, | 2161 0, |
2162 0 | 2162 0 |
2163 ], referenceValidators: [ | 2163 ], referenceValidators: [ |
2164 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2164 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
2165 expectedKind: ReferenceKind.constructor, | 2165 expectedKind: ReferenceKind.constructor, |
2166 prefixExpectations: [ | 2166 prefixExpectations: [ |
2167 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2167 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2168 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2168 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
2169 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2169 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2170 ]) | 2170 ]) |
2171 ]); | 2171 ]); |
2172 } | 2172 } |
2173 | 2173 |
2174 test_constExpr_invokeConstructor_unnamed() { | 2174 test_constExpr_invokeConstructor_unnamed() { |
2175 UnlinkedVariable variable = serializeVariableText(''' | 2175 UnlinkedVariable variable = serializeVariableText(''' |
2176 class C { | 2176 class C { |
2177 const C(a, b, c, d, {e, f, g}); | 2177 const C(a, b, c, d, {e, f, g}); |
2178 } | 2178 } |
2179 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66); | 2179 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66); |
2180 '''); | 2180 '''); |
2181 // Stack: 11 22 3.3 '444' 55 '777' 66 ^head | 2181 // Stack: 11 22 3.3 '444' 55 '777' 66 ^head |
2182 // Ints: ^pointer 3 4 | 2182 // Ints: ^pointer 3 4 |
2183 // Doubles: ^pointer | 2183 // Doubles: ^pointer |
2184 // Strings: ^pointer 'e' 'g' 'f' '' | 2184 // Strings: ^pointer 'e' 'g' 'f' '' |
2185 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2185 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2186 UnlinkedConstOperation.pushInt, | 2186 UnlinkedExprOperation.pushInt, |
2187 UnlinkedConstOperation.pushInt, | 2187 UnlinkedExprOperation.pushInt, |
2188 UnlinkedConstOperation.pushDouble, | 2188 UnlinkedExprOperation.pushDouble, |
2189 UnlinkedConstOperation.pushString, | 2189 UnlinkedExprOperation.pushString, |
2190 UnlinkedConstOperation.pushInt, | 2190 UnlinkedExprOperation.pushInt, |
2191 UnlinkedConstOperation.pushString, | 2191 UnlinkedExprOperation.pushString, |
2192 UnlinkedConstOperation.pushInt, | 2192 UnlinkedExprOperation.pushInt, |
2193 UnlinkedConstOperation.invokeConstructor, | 2193 UnlinkedExprOperation.invokeConstructor, |
2194 ], ints: [ | 2194 ], ints: [ |
2195 11, | 2195 11, |
2196 22, | 2196 22, |
2197 55, | 2197 55, |
2198 66, | 2198 66, |
2199 3, | 2199 3, |
2200 4, | 2200 4, |
2201 ], doubles: [ | 2201 ], doubles: [ |
2202 3.3 | 2202 3.3 |
2203 ], strings: [ | 2203 ], strings: [ |
(...skipping 14 matching lines...) Expand all Loading... |
2218 ''' | 2218 ''' |
2219 class C { | 2219 class C { |
2220 const C(); | 2220 const C(); |
2221 } | 2221 } |
2222 '''); | 2222 '''); |
2223 UnlinkedVariable variable = serializeVariableText(''' | 2223 UnlinkedVariable variable = serializeVariableText(''' |
2224 import 'a.dart'; | 2224 import 'a.dart'; |
2225 const v = const C(); | 2225 const v = const C(); |
2226 '''); | 2226 '''); |
2227 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2227 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2228 UnlinkedConstOperation.invokeConstructor, | 2228 UnlinkedExprOperation.invokeConstructor, |
2229 ], ints: [ | 2229 ], ints: [ |
2230 0, | 2230 0, |
2231 0 | 2231 0 |
2232 ], referenceValidators: [ | 2232 ], referenceValidators: [ |
2233 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2233 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
2234 expectedKind: ReferenceKind.classOrEnum) | 2234 expectedKind: ReferenceKind.classOrEnum) |
2235 ]); | 2235 ]); |
2236 } | 2236 } |
2237 | 2237 |
2238 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() { | 2238 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() { |
2239 addNamedSource( | 2239 addNamedSource( |
2240 '/a.dart', | 2240 '/a.dart', |
2241 ''' | 2241 ''' |
2242 class C { | 2242 class C { |
2243 const C(); | 2243 const C(); |
2244 } | 2244 } |
2245 '''); | 2245 '''); |
2246 UnlinkedVariable variable = serializeVariableText(''' | 2246 UnlinkedVariable variable = serializeVariableText(''' |
2247 import 'a.dart' as p; | 2247 import 'a.dart' as p; |
2248 const v = const p.C(); | 2248 const v = const p.C(); |
2249 '''); | 2249 '''); |
2250 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2250 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2251 UnlinkedConstOperation.invokeConstructor, | 2251 UnlinkedExprOperation.invokeConstructor, |
2252 ], ints: [ | 2252 ], ints: [ |
2253 0, | 2253 0, |
2254 0 | 2254 0 |
2255 ], referenceValidators: [ | 2255 ], referenceValidators: [ |
2256 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2256 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
2257 expectedKind: ReferenceKind.classOrEnum, | 2257 expectedKind: ReferenceKind.classOrEnum, |
2258 prefixExpectations: [ | 2258 prefixExpectations: [ |
2259 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2259 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2260 ]) | 2260 ]) |
2261 ]); | 2261 ]); |
2262 } | 2262 } |
2263 | 2263 |
2264 test_constExpr_invokeConstructor_unresolved_named() { | 2264 test_constExpr_invokeConstructor_unresolved_named() { |
2265 UnlinkedVariable variable = serializeVariableText( | 2265 UnlinkedVariable variable = serializeVariableText( |
2266 ''' | 2266 ''' |
2267 class C {} | 2267 class C {} |
2268 const v = const C.foo(); | 2268 const v = const C.foo(); |
2269 ''', | 2269 ''', |
2270 allowErrors: true); | 2270 allowErrors: true); |
2271 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2271 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2272 UnlinkedConstOperation.invokeConstructor, | 2272 UnlinkedExprOperation.invokeConstructor, |
2273 ], ints: [ | 2273 ], ints: [ |
2274 0, | 2274 0, |
2275 0 | 2275 0 |
2276 ], referenceValidators: [ | 2276 ], referenceValidators: [ |
2277 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2277 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
2278 expectedKind: ReferenceKind.unresolved, | 2278 expectedKind: ReferenceKind.unresolved, |
2279 prefixExpectations: [ | 2279 prefixExpectations: [ |
2280 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2280 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2281 ]) | 2281 ]) |
2282 ]); | 2282 ]); |
2283 } | 2283 } |
2284 | 2284 |
2285 test_constExpr_invokeConstructor_unresolved_named2() { | 2285 test_constExpr_invokeConstructor_unresolved_named2() { |
2286 UnlinkedVariable variable = serializeVariableText( | 2286 UnlinkedVariable variable = serializeVariableText( |
2287 ''' | 2287 ''' |
2288 const v = const C.foo(); | 2288 const v = const C.foo(); |
2289 ''', | 2289 ''', |
2290 allowErrors: true); | 2290 allowErrors: true); |
2291 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2291 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2292 UnlinkedConstOperation.invokeConstructor, | 2292 UnlinkedExprOperation.invokeConstructor, |
2293 ], ints: [ | 2293 ], ints: [ |
2294 0, | 2294 0, |
2295 0 | 2295 0 |
2296 ], referenceValidators: [ | 2296 ], referenceValidators: [ |
2297 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2297 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
2298 expectedKind: ReferenceKind.unresolved, | 2298 expectedKind: ReferenceKind.unresolved, |
2299 prefixExpectations: [ | 2299 prefixExpectations: [ |
2300 new _PrefixExpectation(ReferenceKind.unresolved, 'C') | 2300 new _PrefixExpectation(ReferenceKind.unresolved, 'C') |
2301 ]) | 2301 ]) |
2302 ]); | 2302 ]); |
2303 } | 2303 } |
2304 | 2304 |
2305 test_constExpr_invokeConstructor_unresolved_named_prefixed() { | 2305 test_constExpr_invokeConstructor_unresolved_named_prefixed() { |
2306 addNamedSource( | 2306 addNamedSource( |
2307 '/a.dart', | 2307 '/a.dart', |
2308 ''' | 2308 ''' |
2309 class C { | 2309 class C { |
2310 } | 2310 } |
2311 '''); | 2311 '''); |
2312 UnlinkedVariable variable = serializeVariableText( | 2312 UnlinkedVariable variable = serializeVariableText( |
2313 ''' | 2313 ''' |
2314 import 'a.dart' as p; | 2314 import 'a.dart' as p; |
2315 const v = const p.C.foo(); | 2315 const v = const p.C.foo(); |
2316 ''', | 2316 ''', |
2317 allowErrors: true); | 2317 allowErrors: true); |
2318 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2318 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2319 UnlinkedConstOperation.invokeConstructor, | 2319 UnlinkedExprOperation.invokeConstructor, |
2320 ], ints: [ | 2320 ], ints: [ |
2321 0, | 2321 0, |
2322 0 | 2322 0 |
2323 ], referenceValidators: [ | 2323 ], referenceValidators: [ |
2324 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2324 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
2325 expectedKind: ReferenceKind.unresolved, | 2325 expectedKind: ReferenceKind.unresolved, |
2326 prefixExpectations: [ | 2326 prefixExpectations: [ |
2327 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2327 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2328 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2328 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
2329 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2329 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2330 ]) | 2330 ]) |
2331 ]); | 2331 ]); |
2332 } | 2332 } |
2333 | 2333 |
2334 test_constExpr_invokeConstructor_unresolved_named_prefixed2() { | 2334 test_constExpr_invokeConstructor_unresolved_named_prefixed2() { |
2335 addNamedSource('/a.dart', ''); | 2335 addNamedSource('/a.dart', ''); |
2336 UnlinkedVariable variable = serializeVariableText( | 2336 UnlinkedVariable variable = serializeVariableText( |
2337 ''' | 2337 ''' |
2338 import 'a.dart' as p; | 2338 import 'a.dart' as p; |
2339 const v = const p.C.foo(); | 2339 const v = const p.C.foo(); |
2340 ''', | 2340 ''', |
2341 allowErrors: true); | 2341 allowErrors: true); |
2342 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2342 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2343 UnlinkedConstOperation.invokeConstructor, | 2343 UnlinkedExprOperation.invokeConstructor, |
2344 ], ints: [ | 2344 ], ints: [ |
2345 0, | 2345 0, |
2346 0 | 2346 0 |
2347 ], referenceValidators: [ | 2347 ], referenceValidators: [ |
2348 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2348 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
2349 expectedKind: ReferenceKind.unresolved, | 2349 expectedKind: ReferenceKind.unresolved, |
2350 prefixExpectations: [ | 2350 prefixExpectations: [ |
2351 new _PrefixExpectation(ReferenceKind.unresolved, 'C'), | 2351 new _PrefixExpectation(ReferenceKind.unresolved, 'C'), |
2352 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2352 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2353 ]) | 2353 ]) |
2354 ]); | 2354 ]); |
2355 } | 2355 } |
2356 | 2356 |
2357 test_constExpr_invokeConstructor_unresolved_unnamed() { | 2357 test_constExpr_invokeConstructor_unresolved_unnamed() { |
2358 UnlinkedVariable variable = serializeVariableText( | 2358 UnlinkedVariable variable = serializeVariableText( |
2359 ''' | 2359 ''' |
2360 const v = const Foo(); | 2360 const v = const Foo(); |
2361 ''', | 2361 ''', |
2362 allowErrors: true); | 2362 allowErrors: true); |
2363 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2363 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2364 UnlinkedConstOperation.invokeConstructor, | 2364 UnlinkedExprOperation.invokeConstructor, |
2365 ], ints: [ | 2365 ], ints: [ |
2366 0, | 2366 0, |
2367 0 | 2367 0 |
2368 ], referenceValidators: [ | 2368 ], referenceValidators: [ |
2369 (EntityRef r) => checkTypeRef(r, null, null, 'Foo', | 2369 (EntityRef r) => checkTypeRef(r, null, null, 'Foo', |
2370 expectedKind: ReferenceKind.unresolved) | 2370 expectedKind: ReferenceKind.unresolved) |
2371 ]); | 2371 ]); |
2372 } | 2372 } |
2373 | 2373 |
2374 test_constExpr_invokeMethodRef_identical() { | 2374 test_constExpr_invokeMethodRef_identical() { |
2375 UnlinkedVariable variable = | 2375 UnlinkedVariable variable = |
2376 serializeVariableText('const v = identical(42, null);'); | 2376 serializeVariableText('const v = identical(42, null);'); |
2377 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2377 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2378 UnlinkedConstOperation.pushInt, | 2378 UnlinkedExprOperation.pushInt, |
2379 UnlinkedConstOperation.pushNull, | 2379 UnlinkedExprOperation.pushNull, |
2380 UnlinkedConstOperation.invokeMethodRef | 2380 UnlinkedExprOperation.invokeMethodRef |
2381 ], ints: [ | 2381 ], ints: [ |
2382 42, | 2382 42, |
2383 0, | 2383 0, |
2384 2, | 2384 2, |
2385 0 | 2385 0 |
2386 ], referenceValidators: [ | 2386 ], referenceValidators: [ |
2387 (EntityRef r) { | 2387 (EntityRef r) { |
2388 checkTypeRef(r, 'dart:core', 'dart:core', 'identical', | 2388 checkTypeRef(r, 'dart:core', 'dart:core', 'identical', |
2389 expectedKind: ReferenceKind.topLevelFunction); | 2389 expectedKind: ReferenceKind.topLevelFunction); |
2390 } | 2390 } |
2391 ]); | 2391 ]); |
2392 } | 2392 } |
2393 | 2393 |
2394 test_constExpr_length_classConstField() { | 2394 test_constExpr_length_classConstField() { |
2395 UnlinkedVariable variable = serializeVariableText(''' | 2395 UnlinkedVariable variable = serializeVariableText(''' |
2396 class C { | 2396 class C { |
2397 static const int length = 0; | 2397 static const int length = 0; |
2398 } | 2398 } |
2399 const int v = C.length; | 2399 const int v = C.length; |
2400 '''); | 2400 '''); |
2401 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2401 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2402 UnlinkedConstOperation.pushReference | 2402 UnlinkedExprOperation.pushReference |
2403 ], referenceValidators: [ | 2403 ], referenceValidators: [ |
2404 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2404 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2405 expectedKind: ReferenceKind.propertyAccessor, | 2405 expectedKind: ReferenceKind.propertyAccessor, |
2406 prefixExpectations: [ | 2406 prefixExpectations: [ |
2407 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2407 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2408 ]) | 2408 ]) |
2409 ]); | 2409 ]); |
2410 } | 2410 } |
2411 | 2411 |
2412 test_constExpr_length_classConstField_imported_withPrefix() { | 2412 test_constExpr_length_classConstField_imported_withPrefix() { |
2413 addNamedSource( | 2413 addNamedSource( |
2414 '/a.dart', | 2414 '/a.dart', |
2415 ''' | 2415 ''' |
2416 class C { | 2416 class C { |
2417 static const int length = 0; | 2417 static const int length = 0; |
2418 } | 2418 } |
2419 '''); | 2419 '''); |
2420 UnlinkedVariable variable = serializeVariableText(''' | 2420 UnlinkedVariable variable = serializeVariableText(''' |
2421 import 'a.dart' as p; | 2421 import 'a.dart' as p; |
2422 const int v = p.C.length; | 2422 const int v = p.C.length; |
2423 '''); | 2423 '''); |
2424 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2424 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2425 UnlinkedConstOperation.pushReference | 2425 UnlinkedExprOperation.pushReference |
2426 ], referenceValidators: [ | 2426 ], referenceValidators: [ |
2427 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2427 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2428 expectedKind: ReferenceKind.propertyAccessor, | 2428 expectedKind: ReferenceKind.propertyAccessor, |
2429 prefixExpectations: [ | 2429 prefixExpectations: [ |
2430 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2430 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2431 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2431 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
2432 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2432 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2433 ]) | 2433 ]) |
2434 ]); | 2434 ]); |
2435 } | 2435 } |
2436 | 2436 |
2437 test_constExpr_length_identifierTarget() { | 2437 test_constExpr_length_identifierTarget() { |
2438 UnlinkedVariable variable = serializeVariableText(''' | 2438 UnlinkedVariable variable = serializeVariableText(''' |
2439 const String a = 'aaa'; | 2439 const String a = 'aaa'; |
2440 const int v = a.length; | 2440 const int v = a.length; |
2441 '''); | 2441 '''); |
2442 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2442 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2443 UnlinkedConstOperation.pushReference | 2443 UnlinkedExprOperation.pushReference |
2444 ], referenceValidators: [ | 2444 ], referenceValidators: [ |
2445 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2445 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2446 expectedKind: ReferenceKind.unresolved, | 2446 expectedKind: ReferenceKind.unresolved, |
2447 unresolvedHasName: true, | 2447 unresolvedHasName: true, |
2448 prefixExpectations: [ | 2448 prefixExpectations: [ |
2449 new _PrefixExpectation( | 2449 new _PrefixExpectation( |
2450 ReferenceKind.topLevelPropertyAccessor, 'a') | 2450 ReferenceKind.topLevelPropertyAccessor, 'a') |
2451 ]) | 2451 ]) |
2452 ]); | 2452 ]); |
2453 } | 2453 } |
2454 | 2454 |
2455 test_constExpr_length_identifierTarget_classConstField() { | 2455 test_constExpr_length_identifierTarget_classConstField() { |
2456 UnlinkedVariable variable = serializeVariableText(''' | 2456 UnlinkedVariable variable = serializeVariableText(''' |
2457 class C { | 2457 class C { |
2458 static const String F = ''; | 2458 static const String F = ''; |
2459 } | 2459 } |
2460 const int v = C.F.length; | 2460 const int v = C.F.length; |
2461 '''); | 2461 '''); |
2462 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2462 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2463 UnlinkedConstOperation.pushReference | 2463 UnlinkedExprOperation.pushReference |
2464 ], referenceValidators: [ | 2464 ], referenceValidators: [ |
2465 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2465 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2466 expectedKind: ReferenceKind.unresolved, | 2466 expectedKind: ReferenceKind.unresolved, |
2467 unresolvedHasName: true, | 2467 unresolvedHasName: true, |
2468 prefixExpectations: [ | 2468 prefixExpectations: [ |
2469 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'), | 2469 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'), |
2470 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), | 2470 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), |
2471 ]) | 2471 ]) |
2472 ]); | 2472 ]); |
2473 } | 2473 } |
2474 | 2474 |
2475 test_constExpr_length_identifierTarget_imported() { | 2475 test_constExpr_length_identifierTarget_imported() { |
2476 addNamedSource( | 2476 addNamedSource( |
2477 '/a.dart', | 2477 '/a.dart', |
2478 ''' | 2478 ''' |
2479 const String a = 'aaa'; | 2479 const String a = 'aaa'; |
2480 '''); | 2480 '''); |
2481 UnlinkedVariable variable = serializeVariableText(''' | 2481 UnlinkedVariable variable = serializeVariableText(''' |
2482 import 'a.dart'; | 2482 import 'a.dart'; |
2483 const int v = a.length; | 2483 const int v = a.length; |
2484 '''); | 2484 '''); |
2485 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2485 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2486 UnlinkedConstOperation.pushReference | 2486 UnlinkedExprOperation.pushReference |
2487 ], referenceValidators: [ | 2487 ], referenceValidators: [ |
2488 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2488 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2489 expectedKind: ReferenceKind.unresolved, | 2489 expectedKind: ReferenceKind.unresolved, |
2490 unresolvedHasName: true, | 2490 unresolvedHasName: true, |
2491 prefixExpectations: [ | 2491 prefixExpectations: [ |
2492 new _PrefixExpectation( | 2492 new _PrefixExpectation( |
2493 ReferenceKind.topLevelPropertyAccessor, 'a', | 2493 ReferenceKind.topLevelPropertyAccessor, 'a', |
2494 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2494 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
2495 ]) | 2495 ]) |
2496 ]); | 2496 ]); |
2497 } | 2497 } |
2498 | 2498 |
2499 test_constExpr_length_identifierTarget_imported_withPrefix() { | 2499 test_constExpr_length_identifierTarget_imported_withPrefix() { |
2500 addNamedSource( | 2500 addNamedSource( |
2501 '/a.dart', | 2501 '/a.dart', |
2502 ''' | 2502 ''' |
2503 const String a = 'aaa'; | 2503 const String a = 'aaa'; |
2504 '''); | 2504 '''); |
2505 UnlinkedVariable variable = serializeVariableText(''' | 2505 UnlinkedVariable variable = serializeVariableText(''' |
2506 import 'a.dart' as p; | 2506 import 'a.dart' as p; |
2507 const int v = p.a.length; | 2507 const int v = p.a.length; |
2508 '''); | 2508 '''); |
2509 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2509 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2510 UnlinkedConstOperation.pushReference | 2510 UnlinkedExprOperation.pushReference |
2511 ], referenceValidators: [ | 2511 ], referenceValidators: [ |
2512 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2512 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
2513 expectedKind: ReferenceKind.unresolved, | 2513 expectedKind: ReferenceKind.unresolved, |
2514 unresolvedHasName: true, | 2514 unresolvedHasName: true, |
2515 prefixExpectations: [ | 2515 prefixExpectations: [ |
2516 new _PrefixExpectation( | 2516 new _PrefixExpectation( |
2517 ReferenceKind.topLevelPropertyAccessor, 'a', | 2517 ReferenceKind.topLevelPropertyAccessor, 'a', |
2518 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2518 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
2519 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2519 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
2520 ]) | 2520 ]) |
2521 ]); | 2521 ]); |
2522 } | 2522 } |
2523 | 2523 |
2524 test_constExpr_length_parenthesizedBinaryTarget() { | 2524 test_constExpr_length_parenthesizedBinaryTarget() { |
2525 UnlinkedVariable variable = | 2525 UnlinkedVariable variable = |
2526 serializeVariableText('const v = ("abc" + "edf").length;'); | 2526 serializeVariableText('const v = ("abc" + "edf").length;'); |
2527 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2527 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2528 UnlinkedConstOperation.pushString, | 2528 UnlinkedExprOperation.pushString, |
2529 UnlinkedConstOperation.pushString, | 2529 UnlinkedExprOperation.pushString, |
2530 UnlinkedConstOperation.add, | 2530 UnlinkedExprOperation.add, |
2531 UnlinkedConstOperation.extractProperty | 2531 UnlinkedExprOperation.extractProperty |
2532 ], strings: [ | 2532 ], strings: [ |
2533 'abc', | 2533 'abc', |
2534 'edf', | 2534 'edf', |
2535 'length' | 2535 'length' |
2536 ]); | 2536 ]); |
2537 } | 2537 } |
2538 | 2538 |
2539 test_constExpr_length_parenthesizedStringTarget() { | 2539 test_constExpr_length_parenthesizedStringTarget() { |
2540 UnlinkedVariable variable = | 2540 UnlinkedVariable variable = |
2541 serializeVariableText('const v = ("abc").length;'); | 2541 serializeVariableText('const v = ("abc").length;'); |
2542 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2542 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2543 UnlinkedConstOperation.pushString, | 2543 UnlinkedExprOperation.pushString, |
2544 UnlinkedConstOperation.extractProperty | 2544 UnlinkedExprOperation.extractProperty |
2545 ], strings: [ | 2545 ], strings: [ |
2546 'abc', | 2546 'abc', |
2547 'length' | 2547 'length' |
2548 ]); | 2548 ]); |
2549 } | 2549 } |
2550 | 2550 |
2551 test_constExpr_length_stringLiteralTarget() { | 2551 test_constExpr_length_stringLiteralTarget() { |
2552 UnlinkedVariable variable = | 2552 UnlinkedVariable variable = |
2553 serializeVariableText('const v = "abc".length;'); | 2553 serializeVariableText('const v = "abc".length;'); |
2554 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2554 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2555 UnlinkedConstOperation.pushString, | 2555 UnlinkedExprOperation.pushString, |
2556 UnlinkedConstOperation.extractProperty | 2556 UnlinkedExprOperation.extractProperty |
2557 ], strings: [ | 2557 ], strings: [ |
2558 'abc', | 2558 'abc', |
2559 'length' | 2559 'length' |
2560 ]); | 2560 ]); |
2561 } | 2561 } |
2562 | 2562 |
2563 test_constExpr_makeSymbol() { | 2563 test_constExpr_makeSymbol() { |
2564 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); | 2564 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); |
2565 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2565 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2566 operators: [UnlinkedConstOperation.makeSymbol], strings: ['a.bb.ccc']); | 2566 operators: [UnlinkedExprOperation.makeSymbol], strings: ['a.bb.ccc']); |
2567 } | 2567 } |
2568 | 2568 |
2569 test_constExpr_makeTypedList() { | 2569 test_constExpr_makeTypedList() { |
2570 UnlinkedVariable variable = | 2570 UnlinkedVariable variable = |
2571 serializeVariableText('const v = const <int>[11, 22, 33];'); | 2571 serializeVariableText('const v = const <int>[11, 22, 33];'); |
2572 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2572 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2573 UnlinkedConstOperation.pushInt, | 2573 UnlinkedExprOperation.pushInt, |
2574 UnlinkedConstOperation.pushInt, | 2574 UnlinkedExprOperation.pushInt, |
2575 UnlinkedConstOperation.pushInt, | 2575 UnlinkedExprOperation.pushInt, |
2576 UnlinkedConstOperation.makeTypedList | 2576 UnlinkedExprOperation.makeTypedList |
2577 ], ints: [ | 2577 ], ints: [ |
2578 11, | 2578 11, |
2579 22, | 2579 22, |
2580 33, | 2580 33, |
2581 3 | 2581 3 |
2582 ], referenceValidators: [ | 2582 ], referenceValidators: [ |
2583 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 2583 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', |
2584 expectedKind: ReferenceKind.classOrEnum) | 2584 expectedKind: ReferenceKind.classOrEnum) |
2585 ]); | 2585 ]); |
2586 } | 2586 } |
2587 | 2587 |
2588 test_constExpr_makeTypedList_dynamic() { | 2588 test_constExpr_makeTypedList_dynamic() { |
2589 UnlinkedVariable variable = | 2589 UnlinkedVariable variable = |
2590 serializeVariableText('const v = const <dynamic>[11, 22, 33];'); | 2590 serializeVariableText('const v = const <dynamic>[11, 22, 33];'); |
2591 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2591 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2592 UnlinkedConstOperation.pushInt, | 2592 UnlinkedExprOperation.pushInt, |
2593 UnlinkedConstOperation.pushInt, | 2593 UnlinkedExprOperation.pushInt, |
2594 UnlinkedConstOperation.pushInt, | 2594 UnlinkedExprOperation.pushInt, |
2595 UnlinkedConstOperation.makeTypedList | 2595 UnlinkedExprOperation.makeTypedList |
2596 ], ints: [ | 2596 ], ints: [ |
2597 11, | 2597 11, |
2598 22, | 2598 22, |
2599 33, | 2599 33, |
2600 3 | 2600 3 |
2601 ], referenceValidators: [ | 2601 ], referenceValidators: [ |
2602 (EntityRef r) => checkDynamicTypeRef(r) | 2602 (EntityRef r) => checkDynamicTypeRef(r) |
2603 ]); | 2603 ]); |
2604 } | 2604 } |
2605 | 2605 |
2606 test_constExpr_makeTypedMap() { | 2606 test_constExpr_makeTypedMap() { |
2607 UnlinkedVariable variable = serializeVariableText( | 2607 UnlinkedVariable variable = serializeVariableText( |
2608 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); | 2608 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
2609 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2609 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2610 UnlinkedConstOperation.pushInt, | 2610 UnlinkedExprOperation.pushInt, |
2611 UnlinkedConstOperation.pushString, | 2611 UnlinkedExprOperation.pushString, |
2612 UnlinkedConstOperation.pushInt, | 2612 UnlinkedExprOperation.pushInt, |
2613 UnlinkedConstOperation.pushString, | 2613 UnlinkedExprOperation.pushString, |
2614 UnlinkedConstOperation.pushInt, | 2614 UnlinkedExprOperation.pushInt, |
2615 UnlinkedConstOperation.pushString, | 2615 UnlinkedExprOperation.pushString, |
2616 UnlinkedConstOperation.makeTypedMap | 2616 UnlinkedExprOperation.makeTypedMap |
2617 ], ints: [ | 2617 ], ints: [ |
2618 11, | 2618 11, |
2619 22, | 2619 22, |
2620 33, | 2620 33, |
2621 3 | 2621 3 |
2622 ], strings: [ | 2622 ], strings: [ |
2623 'aaa', | 2623 'aaa', |
2624 'bbb', | 2624 'bbb', |
2625 'ccc' | 2625 'ccc' |
2626 ], referenceValidators: [ | 2626 ], referenceValidators: [ |
2627 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 2627 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', |
2628 expectedKind: ReferenceKind.classOrEnum), | 2628 expectedKind: ReferenceKind.classOrEnum), |
2629 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', | 2629 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', |
2630 expectedKind: ReferenceKind.classOrEnum) | 2630 expectedKind: ReferenceKind.classOrEnum) |
2631 ]); | 2631 ]); |
2632 } | 2632 } |
2633 | 2633 |
2634 test_constExpr_makeTypedMap_dynamic() { | 2634 test_constExpr_makeTypedMap_dynamic() { |
2635 UnlinkedVariable variable = serializeVariableText( | 2635 UnlinkedVariable variable = serializeVariableText( |
2636 'const v = const <dynamic, dynamic>{11: "aaa", 22: "bbb", 33: "ccc"};'); | 2636 'const v = const <dynamic, dynamic>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
2637 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2637 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2638 UnlinkedConstOperation.pushInt, | 2638 UnlinkedExprOperation.pushInt, |
2639 UnlinkedConstOperation.pushString, | 2639 UnlinkedExprOperation.pushString, |
2640 UnlinkedConstOperation.pushInt, | 2640 UnlinkedExprOperation.pushInt, |
2641 UnlinkedConstOperation.pushString, | 2641 UnlinkedExprOperation.pushString, |
2642 UnlinkedConstOperation.pushInt, | 2642 UnlinkedExprOperation.pushInt, |
2643 UnlinkedConstOperation.pushString, | 2643 UnlinkedExprOperation.pushString, |
2644 UnlinkedConstOperation.makeTypedMap | 2644 UnlinkedExprOperation.makeTypedMap |
2645 ], ints: [ | 2645 ], ints: [ |
2646 11, | 2646 11, |
2647 22, | 2647 22, |
2648 33, | 2648 33, |
2649 3 | 2649 3 |
2650 ], strings: [ | 2650 ], strings: [ |
2651 'aaa', | 2651 'aaa', |
2652 'bbb', | 2652 'bbb', |
2653 'ccc' | 2653 'ccc' |
2654 ], referenceValidators: [ | 2654 ], referenceValidators: [ |
2655 (EntityRef r) => checkDynamicTypeRef(r), | 2655 (EntityRef r) => checkDynamicTypeRef(r), |
2656 (EntityRef r) => checkDynamicTypeRef(r) | 2656 (EntityRef r) => checkDynamicTypeRef(r) |
2657 ]); | 2657 ]); |
2658 } | 2658 } |
2659 | 2659 |
2660 test_constExpr_makeUntypedList() { | 2660 test_constExpr_makeUntypedList() { |
2661 UnlinkedVariable variable = | 2661 UnlinkedVariable variable = |
2662 serializeVariableText('const v = const [11, 22, 33];'); | 2662 serializeVariableText('const v = const [11, 22, 33];'); |
2663 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2663 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2664 UnlinkedConstOperation.pushInt, | 2664 UnlinkedExprOperation.pushInt, |
2665 UnlinkedConstOperation.pushInt, | 2665 UnlinkedExprOperation.pushInt, |
2666 UnlinkedConstOperation.pushInt, | 2666 UnlinkedExprOperation.pushInt, |
2667 UnlinkedConstOperation.makeUntypedList | 2667 UnlinkedExprOperation.makeUntypedList |
2668 ], ints: [ | 2668 ], ints: [ |
2669 11, | 2669 11, |
2670 22, | 2670 22, |
2671 33, | 2671 33, |
2672 3 | 2672 3 |
2673 ]); | 2673 ]); |
2674 } | 2674 } |
2675 | 2675 |
2676 test_constExpr_makeUntypedMap() { | 2676 test_constExpr_makeUntypedMap() { |
2677 UnlinkedVariable variable = serializeVariableText( | 2677 UnlinkedVariable variable = serializeVariableText( |
2678 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};'); | 2678 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};'); |
2679 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2679 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2680 UnlinkedConstOperation.pushInt, | 2680 UnlinkedExprOperation.pushInt, |
2681 UnlinkedConstOperation.pushString, | 2681 UnlinkedExprOperation.pushString, |
2682 UnlinkedConstOperation.pushInt, | 2682 UnlinkedExprOperation.pushInt, |
2683 UnlinkedConstOperation.pushString, | 2683 UnlinkedExprOperation.pushString, |
2684 UnlinkedConstOperation.pushInt, | 2684 UnlinkedExprOperation.pushInt, |
2685 UnlinkedConstOperation.pushString, | 2685 UnlinkedExprOperation.pushString, |
2686 UnlinkedConstOperation.makeUntypedMap | 2686 UnlinkedExprOperation.makeUntypedMap |
2687 ], ints: [ | 2687 ], ints: [ |
2688 11, | 2688 11, |
2689 22, | 2689 22, |
2690 33, | 2690 33, |
2691 3 | 2691 3 |
2692 ], strings: [ | 2692 ], strings: [ |
2693 'aaa', | 2693 'aaa', |
2694 'bbb', | 2694 'bbb', |
2695 'ccc' | 2695 'ccc' |
2696 ]); | 2696 ]); |
2697 } | 2697 } |
2698 | 2698 |
2699 test_constExpr_parenthesized() { | 2699 test_constExpr_parenthesized() { |
2700 UnlinkedVariable variable = serializeVariableText('const v = (1 + 2) * 3;'); | 2700 UnlinkedVariable variable = serializeVariableText('const v = (1 + 2) * 3;'); |
2701 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2701 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2702 UnlinkedConstOperation.pushInt, | 2702 UnlinkedExprOperation.pushInt, |
2703 UnlinkedConstOperation.pushInt, | 2703 UnlinkedExprOperation.pushInt, |
2704 UnlinkedConstOperation.add, | 2704 UnlinkedExprOperation.add, |
2705 UnlinkedConstOperation.pushInt, | 2705 UnlinkedExprOperation.pushInt, |
2706 UnlinkedConstOperation.multiply, | 2706 UnlinkedExprOperation.multiply, |
2707 ], ints: [ | 2707 ], ints: [ |
2708 1, | 2708 1, |
2709 2, | 2709 2, |
2710 3 | 2710 3 |
2711 ]); | 2711 ]); |
2712 } | 2712 } |
2713 | 2713 |
2714 test_constExpr_prefix_complement() { | 2714 test_constExpr_prefix_complement() { |
2715 UnlinkedVariable variable = serializeVariableText('const v = ~2;'); | 2715 UnlinkedVariable variable = serializeVariableText('const v = ~2;'); |
2716 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2716 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2717 UnlinkedConstOperation.pushInt, | 2717 UnlinkedExprOperation.pushInt, |
2718 UnlinkedConstOperation.complement | 2718 UnlinkedExprOperation.complement |
2719 ], ints: [ | 2719 ], ints: [ |
2720 2 | 2720 2 |
2721 ]); | 2721 ]); |
2722 } | 2722 } |
2723 | 2723 |
2724 test_constExpr_prefix_negate() { | 2724 test_constExpr_prefix_negate() { |
2725 UnlinkedVariable variable = serializeVariableText('const v = -(2);'); | 2725 UnlinkedVariable variable = serializeVariableText('const v = -(2);'); |
2726 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2726 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2727 UnlinkedConstOperation.pushInt, | 2727 UnlinkedExprOperation.pushInt, |
2728 UnlinkedConstOperation.negate | 2728 UnlinkedExprOperation.negate |
2729 ], ints: [ | 2729 ], ints: [ |
2730 2 | 2730 2 |
2731 ]); | 2731 ]); |
2732 } | 2732 } |
2733 | 2733 |
2734 test_constExpr_prefix_not() { | 2734 test_constExpr_prefix_not() { |
2735 UnlinkedVariable variable = serializeVariableText('const v = !true;'); | 2735 UnlinkedVariable variable = serializeVariableText('const v = !true;'); |
2736 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2736 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2737 UnlinkedConstOperation.pushTrue, | 2737 operators: [UnlinkedExprOperation.pushTrue, UnlinkedExprOperation.not]); |
2738 UnlinkedConstOperation.not | |
2739 ]); | |
2740 } | 2738 } |
2741 | 2739 |
2742 test_constExpr_pushDouble() { | 2740 test_constExpr_pushDouble() { |
2743 UnlinkedVariable variable = serializeVariableText('const v = 123.4567;'); | 2741 UnlinkedVariable variable = serializeVariableText('const v = 123.4567;'); |
2744 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2742 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2745 operators: [UnlinkedConstOperation.pushDouble], doubles: [123.4567]); | 2743 operators: [UnlinkedExprOperation.pushDouble], doubles: [123.4567]); |
2746 } | 2744 } |
2747 | 2745 |
2748 test_constExpr_pushFalse() { | 2746 test_constExpr_pushFalse() { |
2749 UnlinkedVariable variable = serializeVariableText('const v = false;'); | 2747 UnlinkedVariable variable = serializeVariableText('const v = false;'); |
2750 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2748 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2751 operators: [UnlinkedConstOperation.pushFalse]); | 2749 operators: [UnlinkedExprOperation.pushFalse]); |
2752 } | 2750 } |
2753 | 2751 |
2754 test_constExpr_pushInt() { | 2752 test_constExpr_pushInt() { |
2755 UnlinkedVariable variable = serializeVariableText('const v = 1;'); | 2753 UnlinkedVariable variable = serializeVariableText('const v = 1;'); |
2756 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2754 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2757 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 2755 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
2758 } | 2756 } |
2759 | 2757 |
2760 test_constExpr_pushInt_max() { | 2758 test_constExpr_pushInt_max() { |
2761 UnlinkedVariable variable = serializeVariableText('const v = 0xFFFFFFFF;'); | 2759 UnlinkedVariable variable = serializeVariableText('const v = 0xFFFFFFFF;'); |
2762 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2760 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2763 UnlinkedConstOperation.pushInt, | 2761 UnlinkedExprOperation.pushInt, |
2764 ], ints: [ | 2762 ], ints: [ |
2765 0xFFFFFFFF | 2763 0xFFFFFFFF |
2766 ]); | 2764 ]); |
2767 } | 2765 } |
2768 | 2766 |
2769 test_constExpr_pushInt_negative() { | 2767 test_constExpr_pushInt_negative() { |
2770 UnlinkedVariable variable = serializeVariableText('const v = -5;'); | 2768 UnlinkedVariable variable = serializeVariableText('const v = -5;'); |
2771 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2769 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2772 UnlinkedConstOperation.pushInt, | 2770 UnlinkedExprOperation.pushInt, |
2773 UnlinkedConstOperation.negate | 2771 UnlinkedExprOperation.negate |
2774 ], ints: [ | 2772 ], ints: [ |
2775 5 | 2773 5 |
2776 ]); | 2774 ]); |
2777 } | 2775 } |
2778 | 2776 |
2779 test_constExpr_pushLongInt() { | 2777 test_constExpr_pushLongInt() { |
2780 UnlinkedVariable variable = | 2778 UnlinkedVariable variable = |
2781 serializeVariableText('const v = 0xA123456789ABCDEF012345678;'); | 2779 serializeVariableText('const v = 0xA123456789ABCDEF012345678;'); |
2782 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2780 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2783 operators: [UnlinkedConstOperation.pushLongInt], | 2781 operators: [UnlinkedExprOperation.pushLongInt], |
2784 ints: [4, 0xA, 0x12345678, 0x9ABCDEF0, 0x12345678]); | 2782 ints: [4, 0xA, 0x12345678, 0x9ABCDEF0, 0x12345678]); |
2785 } | 2783 } |
2786 | 2784 |
2787 test_constExpr_pushLongInt_min2() { | 2785 test_constExpr_pushLongInt_min2() { |
2788 UnlinkedVariable variable = serializeVariableText('const v = 0x100000000;'); | 2786 UnlinkedVariable variable = serializeVariableText('const v = 0x100000000;'); |
2789 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2787 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2790 UnlinkedConstOperation.pushLongInt | 2788 UnlinkedExprOperation.pushLongInt |
2791 ], ints: [ | 2789 ], ints: [ |
2792 2, | 2790 2, |
2793 1, | 2791 1, |
2794 0, | 2792 0, |
2795 ]); | 2793 ]); |
2796 } | 2794 } |
2797 | 2795 |
2798 test_constExpr_pushLongInt_min3() { | 2796 test_constExpr_pushLongInt_min3() { |
2799 UnlinkedVariable variable = | 2797 UnlinkedVariable variable = |
2800 serializeVariableText('const v = 0x10000000000000000;'); | 2798 serializeVariableText('const v = 0x10000000000000000;'); |
2801 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2799 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2802 UnlinkedConstOperation.pushLongInt | 2800 UnlinkedExprOperation.pushLongInt |
2803 ], ints: [ | 2801 ], ints: [ |
2804 3, | 2802 3, |
2805 1, | 2803 1, |
2806 0, | 2804 0, |
2807 0, | 2805 0, |
2808 ]); | 2806 ]); |
2809 } | 2807 } |
2810 | 2808 |
2811 test_constExpr_pushNull() { | 2809 test_constExpr_pushNull() { |
2812 UnlinkedVariable variable = serializeVariableText('const v = null;'); | 2810 UnlinkedVariable variable = serializeVariableText('const v = null;'); |
2813 _assertUnlinkedConst(variable.initializer.bodyExpr, | 2811 _assertUnlinkedConst(variable.initializer.bodyExpr, |
2814 operators: [UnlinkedConstOperation.pushNull]); | 2812 operators: [UnlinkedExprOperation.pushNull]); |
2815 } | 2813 } |
2816 | 2814 |
2817 test_constExpr_pushReference_class() { | 2815 test_constExpr_pushReference_class() { |
2818 UnlinkedVariable variable = serializeVariableText(''' | 2816 UnlinkedVariable variable = serializeVariableText(''' |
2819 class C {} | 2817 class C {} |
2820 const v = C; | 2818 const v = C; |
2821 '''); | 2819 '''); |
2822 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2820 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2823 UnlinkedConstOperation.pushReference | 2821 UnlinkedExprOperation.pushReference |
2824 ], referenceValidators: [ | 2822 ], referenceValidators: [ |
2825 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2823 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
2826 expectedKind: ReferenceKind.classOrEnum) | 2824 expectedKind: ReferenceKind.classOrEnum) |
2827 ]); | 2825 ]); |
2828 } | 2826 } |
2829 | 2827 |
2830 test_constExpr_pushReference_enum() { | 2828 test_constExpr_pushReference_enum() { |
2831 UnlinkedVariable variable = serializeVariableText(''' | 2829 UnlinkedVariable variable = serializeVariableText(''' |
2832 enum C {V1, V2, V3} | 2830 enum C {V1, V2, V3} |
2833 const v = C; | 2831 const v = C; |
2834 '''); | 2832 '''); |
2835 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2833 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2836 UnlinkedConstOperation.pushReference | 2834 UnlinkedExprOperation.pushReference |
2837 ], referenceValidators: [ | 2835 ], referenceValidators: [ |
2838 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2836 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
2839 expectedKind: ReferenceKind.classOrEnum) | 2837 expectedKind: ReferenceKind.classOrEnum) |
2840 ]); | 2838 ]); |
2841 } | 2839 } |
2842 | 2840 |
2843 test_constExpr_pushReference_enumValue() { | 2841 test_constExpr_pushReference_enumValue() { |
2844 UnlinkedVariable variable = serializeVariableText(''' | 2842 UnlinkedVariable variable = serializeVariableText(''' |
2845 enum C {V1, V2, V3} | 2843 enum C {V1, V2, V3} |
2846 const v = C.V1; | 2844 const v = C.V1; |
2847 '''); | 2845 '''); |
2848 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2846 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2849 UnlinkedConstOperation.pushReference | 2847 UnlinkedExprOperation.pushReference |
2850 ], referenceValidators: [ | 2848 ], referenceValidators: [ |
2851 (EntityRef r) => checkTypeRef(r, null, null, 'V1', | 2849 (EntityRef r) => checkTypeRef(r, null, null, 'V1', |
2852 expectedKind: ReferenceKind.propertyAccessor, | 2850 expectedKind: ReferenceKind.propertyAccessor, |
2853 prefixExpectations: [ | 2851 prefixExpectations: [ |
2854 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2852 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2855 ]) | 2853 ]) |
2856 ]); | 2854 ]); |
2857 } | 2855 } |
2858 | 2856 |
2859 test_constExpr_pushReference_enumValue_viaImport() { | 2857 test_constExpr_pushReference_enumValue_viaImport() { |
2860 addNamedSource( | 2858 addNamedSource( |
2861 '/a.dart', | 2859 '/a.dart', |
2862 ''' | 2860 ''' |
2863 enum C {V1, V2, V3} | 2861 enum C {V1, V2, V3} |
2864 '''); | 2862 '''); |
2865 UnlinkedVariable variable = serializeVariableText(''' | 2863 UnlinkedVariable variable = serializeVariableText(''' |
2866 import 'a.dart'; | 2864 import 'a.dart'; |
2867 const v = C.V1; | 2865 const v = C.V1; |
2868 '''); | 2866 '''); |
2869 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2867 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2870 UnlinkedConstOperation.pushReference | 2868 UnlinkedExprOperation.pushReference |
2871 ], referenceValidators: [ | 2869 ], referenceValidators: [ |
2872 (EntityRef r) => checkTypeRef(r, null, null, 'V1', | 2870 (EntityRef r) => checkTypeRef(r, null, null, 'V1', |
2873 expectedKind: ReferenceKind.propertyAccessor, | 2871 expectedKind: ReferenceKind.propertyAccessor, |
2874 prefixExpectations: [ | 2872 prefixExpectations: [ |
2875 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2873 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2876 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2874 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
2877 ]) | 2875 ]) |
2878 ]); | 2876 ]); |
2879 } | 2877 } |
2880 | 2878 |
2881 test_constExpr_pushReference_enumValues() { | 2879 test_constExpr_pushReference_enumValues() { |
2882 UnlinkedVariable variable = serializeVariableText(''' | 2880 UnlinkedVariable variable = serializeVariableText(''' |
2883 enum C {V1, V2, V3} | 2881 enum C {V1, V2, V3} |
2884 const v = C.values; | 2882 const v = C.values; |
2885 '''); | 2883 '''); |
2886 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2884 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2887 UnlinkedConstOperation.pushReference | 2885 UnlinkedExprOperation.pushReference |
2888 ], referenceValidators: [ | 2886 ], referenceValidators: [ |
2889 (EntityRef r) => checkTypeRef(r, null, null, 'values', | 2887 (EntityRef r) => checkTypeRef(r, null, null, 'values', |
2890 expectedKind: ReferenceKind.propertyAccessor, | 2888 expectedKind: ReferenceKind.propertyAccessor, |
2891 prefixExpectations: [ | 2889 prefixExpectations: [ |
2892 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2890 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2893 ]) | 2891 ]) |
2894 ]); | 2892 ]); |
2895 } | 2893 } |
2896 | 2894 |
2897 test_constExpr_pushReference_enumValues_viaImport() { | 2895 test_constExpr_pushReference_enumValues_viaImport() { |
2898 addNamedSource( | 2896 addNamedSource( |
2899 '/a.dart', | 2897 '/a.dart', |
2900 ''' | 2898 ''' |
2901 enum C {V1, V2, V3} | 2899 enum C {V1, V2, V3} |
2902 '''); | 2900 '''); |
2903 UnlinkedVariable variable = serializeVariableText(''' | 2901 UnlinkedVariable variable = serializeVariableText(''' |
2904 import 'a.dart'; | 2902 import 'a.dart'; |
2905 const v = C.values; | 2903 const v = C.values; |
2906 '''); | 2904 '''); |
2907 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2905 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2908 UnlinkedConstOperation.pushReference | 2906 UnlinkedExprOperation.pushReference |
2909 ], referenceValidators: [ | 2907 ], referenceValidators: [ |
2910 (EntityRef r) => checkTypeRef(r, null, null, 'values', | 2908 (EntityRef r) => checkTypeRef(r, null, null, 'values', |
2911 expectedKind: ReferenceKind.propertyAccessor, | 2909 expectedKind: ReferenceKind.propertyAccessor, |
2912 prefixExpectations: [ | 2910 prefixExpectations: [ |
2913 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2911 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2914 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2912 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
2915 ]) | 2913 ]) |
2916 ]); | 2914 ]); |
2917 } | 2915 } |
2918 | 2916 |
2919 test_constExpr_pushReference_field() { | 2917 test_constExpr_pushReference_field() { |
2920 UnlinkedVariable variable = serializeVariableText(''' | 2918 UnlinkedVariable variable = serializeVariableText(''' |
2921 class C { | 2919 class C { |
2922 static const int F = 1; | 2920 static const int F = 1; |
2923 } | 2921 } |
2924 const v = C.F; | 2922 const v = C.F; |
2925 '''); | 2923 '''); |
2926 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2924 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2927 UnlinkedConstOperation.pushReference | 2925 UnlinkedExprOperation.pushReference |
2928 ], referenceValidators: [ | 2926 ], referenceValidators: [ |
2929 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 2927 (EntityRef r) => checkTypeRef(r, null, null, 'F', |
2930 expectedKind: ReferenceKind.propertyAccessor, | 2928 expectedKind: ReferenceKind.propertyAccessor, |
2931 prefixExpectations: [ | 2929 prefixExpectations: [ |
2932 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2930 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
2933 ]) | 2931 ]) |
2934 ]); | 2932 ]); |
2935 } | 2933 } |
2936 | 2934 |
2937 test_constExpr_pushReference_field_imported() { | 2935 test_constExpr_pushReference_field_imported() { |
2938 addNamedSource( | 2936 addNamedSource( |
2939 '/a.dart', | 2937 '/a.dart', |
2940 ''' | 2938 ''' |
2941 class C { | 2939 class C { |
2942 static const int F = 1; | 2940 static const int F = 1; |
2943 } | 2941 } |
2944 '''); | 2942 '''); |
2945 UnlinkedVariable variable = serializeVariableText(''' | 2943 UnlinkedVariable variable = serializeVariableText(''' |
2946 import 'a.dart'; | 2944 import 'a.dart'; |
2947 const v = C.F; | 2945 const v = C.F; |
2948 '''); | 2946 '''); |
2949 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2947 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2950 UnlinkedConstOperation.pushReference | 2948 UnlinkedExprOperation.pushReference |
2951 ], referenceValidators: [ | 2949 ], referenceValidators: [ |
2952 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 2950 (EntityRef r) => checkTypeRef(r, null, null, 'F', |
2953 expectedKind: ReferenceKind.propertyAccessor, | 2951 expectedKind: ReferenceKind.propertyAccessor, |
2954 prefixExpectations: [ | 2952 prefixExpectations: [ |
2955 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2953 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2956 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2954 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
2957 ]) | 2955 ]) |
2958 ]); | 2956 ]); |
2959 } | 2957 } |
2960 | 2958 |
2961 test_constExpr_pushReference_field_imported_withPrefix() { | 2959 test_constExpr_pushReference_field_imported_withPrefix() { |
2962 addNamedSource( | 2960 addNamedSource( |
2963 '/a.dart', | 2961 '/a.dart', |
2964 ''' | 2962 ''' |
2965 class C { | 2963 class C { |
2966 static const int F = 1; | 2964 static const int F = 1; |
2967 } | 2965 } |
2968 '''); | 2966 '''); |
2969 UnlinkedVariable variable = serializeVariableText(''' | 2967 UnlinkedVariable variable = serializeVariableText(''' |
2970 import 'a.dart' as p; | 2968 import 'a.dart' as p; |
2971 const v = p.C.F; | 2969 const v = p.C.F; |
2972 '''); | 2970 '''); |
2973 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2971 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2974 UnlinkedConstOperation.pushReference | 2972 UnlinkedExprOperation.pushReference |
2975 ], referenceValidators: [ | 2973 ], referenceValidators: [ |
2976 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 2974 (EntityRef r) => checkTypeRef(r, null, null, 'F', |
2977 expectedKind: ReferenceKind.propertyAccessor, | 2975 expectedKind: ReferenceKind.propertyAccessor, |
2978 prefixExpectations: [ | 2976 prefixExpectations: [ |
2979 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2977 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
2980 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2978 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
2981 new _PrefixExpectation(ReferenceKind.prefix, 'p'), | 2979 new _PrefixExpectation(ReferenceKind.prefix, 'p'), |
2982 ]) | 2980 ]) |
2983 ]); | 2981 ]); |
2984 } | 2982 } |
2985 | 2983 |
2986 test_constExpr_pushReference_field_simpleIdentifier() { | 2984 test_constExpr_pushReference_field_simpleIdentifier() { |
2987 UnlinkedVariable variable = serializeClassText(''' | 2985 UnlinkedVariable variable = serializeClassText(''' |
2988 class C { | 2986 class C { |
2989 static const a = b; | 2987 static const a = b; |
2990 static const b = null; | 2988 static const b = null; |
2991 } | 2989 } |
2992 ''').fields[0]; | 2990 ''').fields[0]; |
2993 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2991 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
2994 UnlinkedConstOperation.pushReference | 2992 UnlinkedExprOperation.pushReference |
2995 ], referenceValidators: [ | 2993 ], referenceValidators: [ |
2996 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 2994 (EntityRef r) => checkTypeRef(r, null, null, 'b', |
2997 expectedKind: ReferenceKind.propertyAccessor, | 2995 expectedKind: ReferenceKind.propertyAccessor, |
2998 prefixExpectations: [ | 2996 prefixExpectations: [ |
2999 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2997 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
3000 ]) | 2998 ]) |
3001 ]); | 2999 ]); |
3002 } | 3000 } |
3003 | 3001 |
3004 test_constExpr_pushReference_staticGetter() { | 3002 test_constExpr_pushReference_staticGetter() { |
3005 UnlinkedVariable variable = serializeVariableText(''' | 3003 UnlinkedVariable variable = serializeVariableText(''' |
3006 class C { | 3004 class C { |
3007 static int get x => null; | 3005 static int get x => null; |
3008 } | 3006 } |
3009 const v = C.x; | 3007 const v = C.x; |
3010 '''); | 3008 '''); |
3011 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3009 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3012 UnlinkedConstOperation.pushReference | 3010 UnlinkedExprOperation.pushReference |
3013 ], referenceValidators: [ | 3011 ], referenceValidators: [ |
3014 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3012 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
3015 expectedKind: ReferenceKind.propertyAccessor, | 3013 expectedKind: ReferenceKind.propertyAccessor, |
3016 prefixExpectations: [ | 3014 prefixExpectations: [ |
3017 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3015 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
3018 ]) | 3016 ]) |
3019 ]); | 3017 ]); |
3020 } | 3018 } |
3021 | 3019 |
3022 test_constExpr_pushReference_staticGetter_imported() { | 3020 test_constExpr_pushReference_staticGetter_imported() { |
3023 addNamedSource( | 3021 addNamedSource( |
3024 '/a.dart', | 3022 '/a.dart', |
3025 ''' | 3023 ''' |
3026 class C { | 3024 class C { |
3027 static int get x => null; | 3025 static int get x => null; |
3028 } | 3026 } |
3029 '''); | 3027 '''); |
3030 UnlinkedVariable variable = serializeVariableText(''' | 3028 UnlinkedVariable variable = serializeVariableText(''' |
3031 import 'a.dart'; | 3029 import 'a.dart'; |
3032 const v = C.x; | 3030 const v = C.x; |
3033 '''); | 3031 '''); |
3034 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3032 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3035 UnlinkedConstOperation.pushReference | 3033 UnlinkedExprOperation.pushReference |
3036 ], referenceValidators: [ | 3034 ], referenceValidators: [ |
3037 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3035 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
3038 expectedKind: ReferenceKind.propertyAccessor, | 3036 expectedKind: ReferenceKind.propertyAccessor, |
3039 prefixExpectations: [ | 3037 prefixExpectations: [ |
3040 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3038 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
3041 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 3039 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
3042 ]) | 3040 ]) |
3043 ]); | 3041 ]); |
3044 } | 3042 } |
3045 | 3043 |
3046 test_constExpr_pushReference_staticGetter_imported_withPrefix() { | 3044 test_constExpr_pushReference_staticGetter_imported_withPrefix() { |
3047 addNamedSource( | 3045 addNamedSource( |
3048 '/a.dart', | 3046 '/a.dart', |
3049 ''' | 3047 ''' |
3050 class C { | 3048 class C { |
3051 static int get x => null; | 3049 static int get x => null; |
3052 } | 3050 } |
3053 '''); | 3051 '''); |
3054 UnlinkedVariable variable = serializeVariableText(''' | 3052 UnlinkedVariable variable = serializeVariableText(''' |
3055 import 'a.dart' as p; | 3053 import 'a.dart' as p; |
3056 const v = p.C.x; | 3054 const v = p.C.x; |
3057 '''); | 3055 '''); |
3058 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3056 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3059 UnlinkedConstOperation.pushReference | 3057 UnlinkedExprOperation.pushReference |
3060 ], referenceValidators: [ | 3058 ], referenceValidators: [ |
3061 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3059 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
3062 expectedKind: ReferenceKind.propertyAccessor, | 3060 expectedKind: ReferenceKind.propertyAccessor, |
3063 prefixExpectations: [ | 3061 prefixExpectations: [ |
3064 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3062 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
3065 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3063 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
3066 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3064 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
3067 ]) | 3065 ]) |
3068 ]); | 3066 ]); |
3069 } | 3067 } |
3070 | 3068 |
3071 test_constExpr_pushReference_staticMethod() { | 3069 test_constExpr_pushReference_staticMethod() { |
3072 UnlinkedVariable variable = serializeVariableText(''' | 3070 UnlinkedVariable variable = serializeVariableText(''' |
3073 class C { | 3071 class C { |
3074 static m() {} | 3072 static m() {} |
3075 } | 3073 } |
3076 const v = C.m; | 3074 const v = C.m; |
3077 '''); | 3075 '''); |
3078 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3076 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3079 UnlinkedConstOperation.pushReference | 3077 UnlinkedExprOperation.pushReference |
3080 ], referenceValidators: [ | 3078 ], referenceValidators: [ |
3081 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3079 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
3082 expectedKind: ReferenceKind.method, | 3080 expectedKind: ReferenceKind.method, |
3083 prefixExpectations: [ | 3081 prefixExpectations: [ |
3084 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3082 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
3085 ]) | 3083 ]) |
3086 ]); | 3084 ]); |
3087 } | 3085 } |
3088 | 3086 |
3089 test_constExpr_pushReference_staticMethod_imported() { | 3087 test_constExpr_pushReference_staticMethod_imported() { |
3090 addNamedSource( | 3088 addNamedSource( |
3091 '/a.dart', | 3089 '/a.dart', |
3092 ''' | 3090 ''' |
3093 class C { | 3091 class C { |
3094 static m() {} | 3092 static m() {} |
3095 } | 3093 } |
3096 '''); | 3094 '''); |
3097 UnlinkedVariable variable = serializeVariableText(''' | 3095 UnlinkedVariable variable = serializeVariableText(''' |
3098 import 'a.dart'; | 3096 import 'a.dart'; |
3099 const v = C.m; | 3097 const v = C.m; |
3100 '''); | 3098 '''); |
3101 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3099 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3102 UnlinkedConstOperation.pushReference | 3100 UnlinkedExprOperation.pushReference |
3103 ], referenceValidators: [ | 3101 ], referenceValidators: [ |
3104 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3102 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
3105 expectedKind: ReferenceKind.method, | 3103 expectedKind: ReferenceKind.method, |
3106 prefixExpectations: [ | 3104 prefixExpectations: [ |
3107 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3105 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
3108 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 3106 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
3109 ]) | 3107 ]) |
3110 ]); | 3108 ]); |
3111 } | 3109 } |
3112 | 3110 |
3113 test_constExpr_pushReference_staticMethod_imported_withPrefix() { | 3111 test_constExpr_pushReference_staticMethod_imported_withPrefix() { |
3114 addNamedSource( | 3112 addNamedSource( |
3115 '/a.dart', | 3113 '/a.dart', |
3116 ''' | 3114 ''' |
3117 class C { | 3115 class C { |
3118 static m() {} | 3116 static m() {} |
3119 } | 3117 } |
3120 '''); | 3118 '''); |
3121 UnlinkedVariable variable = serializeVariableText(''' | 3119 UnlinkedVariable variable = serializeVariableText(''' |
3122 import 'a.dart' as p; | 3120 import 'a.dart' as p; |
3123 const v = p.C.m; | 3121 const v = p.C.m; |
3124 '''); | 3122 '''); |
3125 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3123 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3126 UnlinkedConstOperation.pushReference | 3124 UnlinkedExprOperation.pushReference |
3127 ], referenceValidators: [ | 3125 ], referenceValidators: [ |
3128 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3126 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
3129 expectedKind: ReferenceKind.method, | 3127 expectedKind: ReferenceKind.method, |
3130 prefixExpectations: [ | 3128 prefixExpectations: [ |
3131 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3129 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
3132 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3130 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
3133 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3131 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
3134 ]) | 3132 ]) |
3135 ]); | 3133 ]); |
3136 } | 3134 } |
3137 | 3135 |
3138 test_constExpr_pushReference_staticMethod_simpleIdentifier() { | 3136 test_constExpr_pushReference_staticMethod_simpleIdentifier() { |
3139 UnlinkedVariable variable = serializeClassText(''' | 3137 UnlinkedVariable variable = serializeClassText(''' |
3140 class C { | 3138 class C { |
3141 static const a = m; | 3139 static const a = m; |
3142 static m() {} | 3140 static m() {} |
3143 } | 3141 } |
3144 ''').fields[0]; | 3142 ''').fields[0]; |
3145 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3143 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3146 UnlinkedConstOperation.pushReference | 3144 UnlinkedExprOperation.pushReference |
3147 ], referenceValidators: [ | 3145 ], referenceValidators: [ |
3148 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3146 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
3149 expectedKind: ReferenceKind.method, | 3147 expectedKind: ReferenceKind.method, |
3150 prefixExpectations: [ | 3148 prefixExpectations: [ |
3151 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3149 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
3152 ]) | 3150 ]) |
3153 ]); | 3151 ]); |
3154 } | 3152 } |
3155 | 3153 |
3156 test_constExpr_pushReference_topLevelFunction() { | 3154 test_constExpr_pushReference_topLevelFunction() { |
3157 UnlinkedVariable variable = serializeVariableText(''' | 3155 UnlinkedVariable variable = serializeVariableText(''' |
3158 f() {} | 3156 f() {} |
3159 const v = f; | 3157 const v = f; |
3160 '''); | 3158 '''); |
3161 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3159 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3162 UnlinkedConstOperation.pushReference | 3160 UnlinkedExprOperation.pushReference |
3163 ], referenceValidators: [ | 3161 ], referenceValidators: [ |
3164 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 3162 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
3165 expectedKind: ReferenceKind.topLevelFunction) | 3163 expectedKind: ReferenceKind.topLevelFunction) |
3166 ]); | 3164 ]); |
3167 } | 3165 } |
3168 | 3166 |
3169 test_constExpr_pushReference_topLevelFunction_imported() { | 3167 test_constExpr_pushReference_topLevelFunction_imported() { |
3170 addNamedSource( | 3168 addNamedSource( |
3171 '/a.dart', | 3169 '/a.dart', |
3172 ''' | 3170 ''' |
3173 f() {} | 3171 f() {} |
3174 '''); | 3172 '''); |
3175 UnlinkedVariable variable = serializeVariableText(''' | 3173 UnlinkedVariable variable = serializeVariableText(''' |
3176 import 'a.dart'; | 3174 import 'a.dart'; |
3177 const v = f; | 3175 const v = f; |
3178 '''); | 3176 '''); |
3179 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3177 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3180 UnlinkedConstOperation.pushReference | 3178 UnlinkedExprOperation.pushReference |
3181 ], referenceValidators: [ | 3179 ], referenceValidators: [ |
3182 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', | 3180 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', |
3183 expectedKind: ReferenceKind.topLevelFunction) | 3181 expectedKind: ReferenceKind.topLevelFunction) |
3184 ]); | 3182 ]); |
3185 } | 3183 } |
3186 | 3184 |
3187 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() { | 3185 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() { |
3188 addNamedSource( | 3186 addNamedSource( |
3189 '/a.dart', | 3187 '/a.dart', |
3190 ''' | 3188 ''' |
3191 f() {} | 3189 f() {} |
3192 '''); | 3190 '''); |
3193 UnlinkedVariable variable = serializeVariableText(''' | 3191 UnlinkedVariable variable = serializeVariableText(''' |
3194 import 'a.dart' as p; | 3192 import 'a.dart' as p; |
3195 const v = p.f; | 3193 const v = p.f; |
3196 '''); | 3194 '''); |
3197 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3195 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3198 UnlinkedConstOperation.pushReference | 3196 UnlinkedExprOperation.pushReference |
3199 ], referenceValidators: [ | 3197 ], referenceValidators: [ |
3200 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', | 3198 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', |
3201 expectedKind: ReferenceKind.topLevelFunction, | 3199 expectedKind: ReferenceKind.topLevelFunction, |
3202 prefixExpectations: [ | 3200 prefixExpectations: [ |
3203 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3201 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
3204 ]) | 3202 ]) |
3205 ]); | 3203 ]); |
3206 } | 3204 } |
3207 | 3205 |
3208 test_constExpr_pushReference_topLevelGetter() { | 3206 test_constExpr_pushReference_topLevelGetter() { |
3209 UnlinkedVariable variable = serializeVariableText(''' | 3207 UnlinkedVariable variable = serializeVariableText(''' |
3210 int get x => null; | 3208 int get x => null; |
3211 const v = x; | 3209 const v = x; |
3212 '''); | 3210 '''); |
3213 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3211 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3214 UnlinkedConstOperation.pushReference | 3212 UnlinkedExprOperation.pushReference |
3215 ], referenceValidators: [ | 3213 ], referenceValidators: [ |
3216 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3214 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
3217 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3215 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
3218 ]); | 3216 ]); |
3219 } | 3217 } |
3220 | 3218 |
3221 test_constExpr_pushReference_topLevelGetter_imported() { | 3219 test_constExpr_pushReference_topLevelGetter_imported() { |
3222 addNamedSource('/a.dart', 'int get x => null;'); | 3220 addNamedSource('/a.dart', 'int get x => null;'); |
3223 UnlinkedVariable variable = serializeVariableText(''' | 3221 UnlinkedVariable variable = serializeVariableText(''' |
3224 import 'a.dart'; | 3222 import 'a.dart'; |
3225 const v = x; | 3223 const v = x; |
3226 '''); | 3224 '''); |
3227 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3225 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3228 UnlinkedConstOperation.pushReference | 3226 UnlinkedExprOperation.pushReference |
3229 ], referenceValidators: [ | 3227 ], referenceValidators: [ |
3230 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', | 3228 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', |
3231 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3229 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
3232 ]); | 3230 ]); |
3233 } | 3231 } |
3234 | 3232 |
3235 test_constExpr_pushReference_topLevelGetter_imported_withPrefix() { | 3233 test_constExpr_pushReference_topLevelGetter_imported_withPrefix() { |
3236 addNamedSource('/a.dart', 'int get x => null;'); | 3234 addNamedSource('/a.dart', 'int get x => null;'); |
3237 UnlinkedVariable variable = serializeVariableText(''' | 3235 UnlinkedVariable variable = serializeVariableText(''' |
3238 import 'a.dart' as p; | 3236 import 'a.dart' as p; |
3239 const v = p.x; | 3237 const v = p.x; |
3240 '''); | 3238 '''); |
3241 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3239 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3242 UnlinkedConstOperation.pushReference | 3240 UnlinkedExprOperation.pushReference |
3243 ], referenceValidators: [ | 3241 ], referenceValidators: [ |
3244 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', | 3242 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', |
3245 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 3243 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
3246 expectedPrefix: 'p') | 3244 expectedPrefix: 'p') |
3247 ]); | 3245 ]); |
3248 } | 3246 } |
3249 | 3247 |
3250 test_constExpr_pushReference_topLevelVariable() { | 3248 test_constExpr_pushReference_topLevelVariable() { |
3251 UnlinkedVariable variable = serializeVariableText(''' | 3249 UnlinkedVariable variable = serializeVariableText(''' |
3252 const int a = 1; | 3250 const int a = 1; |
3253 const v = a; | 3251 const v = a; |
3254 '''); | 3252 '''); |
3255 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3253 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3256 UnlinkedConstOperation.pushReference | 3254 UnlinkedExprOperation.pushReference |
3257 ], referenceValidators: [ | 3255 ], referenceValidators: [ |
3258 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 3256 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
3259 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3257 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
3260 ]); | 3258 ]); |
3261 } | 3259 } |
3262 | 3260 |
3263 test_constExpr_pushReference_topLevelVariable_imported() { | 3261 test_constExpr_pushReference_topLevelVariable_imported() { |
3264 addNamedSource('/a.dart', 'const int a = 1;'); | 3262 addNamedSource('/a.dart', 'const int a = 1;'); |
3265 UnlinkedVariable variable = serializeVariableText(''' | 3263 UnlinkedVariable variable = serializeVariableText(''' |
3266 import 'a.dart'; | 3264 import 'a.dart'; |
3267 const v = a; | 3265 const v = a; |
3268 '''); | 3266 '''); |
3269 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3267 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3270 UnlinkedConstOperation.pushReference | 3268 UnlinkedExprOperation.pushReference |
3271 ], referenceValidators: [ | 3269 ], referenceValidators: [ |
3272 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 3270 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
3273 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3271 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
3274 ]); | 3272 ]); |
3275 } | 3273 } |
3276 | 3274 |
3277 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() { | 3275 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() { |
3278 addNamedSource('/a.dart', 'const int a = 1;'); | 3276 addNamedSource('/a.dart', 'const int a = 1;'); |
3279 UnlinkedVariable variable = serializeVariableText(''' | 3277 UnlinkedVariable variable = serializeVariableText(''' |
3280 import 'a.dart' as p; | 3278 import 'a.dart' as p; |
3281 const v = p.a; | 3279 const v = p.a; |
3282 '''); | 3280 '''); |
3283 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3281 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3284 UnlinkedConstOperation.pushReference | 3282 UnlinkedExprOperation.pushReference |
3285 ], referenceValidators: [ | 3283 ], referenceValidators: [ |
3286 (EntityRef r) { | 3284 (EntityRef r) { |
3287 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 3285 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
3288 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 3286 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
3289 expectedPrefix: 'p'); | 3287 expectedPrefix: 'p'); |
3290 } | 3288 } |
3291 ]); | 3289 ]); |
3292 } | 3290 } |
3293 | 3291 |
3294 test_constExpr_pushReference_typeParameter() { | 3292 test_constExpr_pushReference_typeParameter() { |
3295 String text = ''' | 3293 String text = ''' |
3296 class C<T> { | 3294 class C<T> { |
3297 static const a = T; | 3295 static const a = T; |
3298 } | 3296 } |
3299 '''; | 3297 '''; |
3300 UnlinkedVariable variable = | 3298 UnlinkedVariable variable = |
3301 serializeClassText(text, allowErrors: true).fields[0]; | 3299 serializeClassText(text, allowErrors: true).fields[0]; |
3302 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3300 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3303 UnlinkedConstOperation.pushReference | 3301 UnlinkedExprOperation.pushReference |
3304 ], referenceValidators: [ | 3302 ], referenceValidators: [ |
3305 (EntityRef r) { | 3303 (EntityRef r) { |
3306 return checkParamTypeRef(r, 1); | 3304 return checkParamTypeRef(r, 1); |
3307 } | 3305 } |
3308 ]); | 3306 ]); |
3309 } | 3307 } |
3310 | 3308 |
3311 test_constExpr_pushReference_unresolved_prefix0() { | 3309 test_constExpr_pushReference_unresolved_prefix0() { |
3312 UnlinkedVariable variable = serializeVariableText( | 3310 UnlinkedVariable variable = serializeVariableText( |
3313 ''' | 3311 ''' |
3314 const v = foo; | 3312 const v = foo; |
3315 ''', | 3313 ''', |
3316 allowErrors: true); | 3314 allowErrors: true); |
3317 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3315 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3318 UnlinkedConstOperation.pushReference | 3316 UnlinkedExprOperation.pushReference |
3319 ], referenceValidators: [ | 3317 ], referenceValidators: [ |
3320 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3318 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
3321 expectedKind: ReferenceKind.unresolved) | 3319 expectedKind: ReferenceKind.unresolved) |
3322 ]); | 3320 ]); |
3323 } | 3321 } |
3324 | 3322 |
3325 test_constExpr_pushReference_unresolved_prefix1() { | 3323 test_constExpr_pushReference_unresolved_prefix1() { |
3326 UnlinkedVariable variable = serializeVariableText( | 3324 UnlinkedVariable variable = serializeVariableText( |
3327 ''' | 3325 ''' |
3328 class C {} | 3326 class C {} |
3329 const v = C.foo; | 3327 const v = C.foo; |
3330 ''', | 3328 ''', |
3331 allowErrors: true); | 3329 allowErrors: true); |
3332 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3330 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3333 UnlinkedConstOperation.pushReference | 3331 UnlinkedExprOperation.pushReference |
3334 ], referenceValidators: [ | 3332 ], referenceValidators: [ |
3335 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3333 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
3336 expectedKind: ReferenceKind.unresolved, | 3334 expectedKind: ReferenceKind.unresolved, |
3337 prefixExpectations: [ | 3335 prefixExpectations: [ |
3338 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3336 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
3339 ]) | 3337 ]) |
3340 ]); | 3338 ]); |
3341 } | 3339 } |
3342 | 3340 |
3343 test_constExpr_pushReference_unresolved_prefix2() { | 3341 test_constExpr_pushReference_unresolved_prefix2() { |
3344 addNamedSource( | 3342 addNamedSource( |
3345 '/a.dart', | 3343 '/a.dart', |
3346 ''' | 3344 ''' |
3347 class C {} | 3345 class C {} |
3348 '''); | 3346 '''); |
3349 UnlinkedVariable variable = serializeVariableText( | 3347 UnlinkedVariable variable = serializeVariableText( |
3350 ''' | 3348 ''' |
3351 import 'a.dart' as p; | 3349 import 'a.dart' as p; |
3352 const v = p.C.foo; | 3350 const v = p.C.foo; |
3353 ''', | 3351 ''', |
3354 allowErrors: true); | 3352 allowErrors: true); |
3355 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3353 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3356 UnlinkedConstOperation.pushReference | 3354 UnlinkedExprOperation.pushReference |
3357 ], referenceValidators: [ | 3355 ], referenceValidators: [ |
3358 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3356 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
3359 expectedKind: ReferenceKind.unresolved, | 3357 expectedKind: ReferenceKind.unresolved, |
3360 prefixExpectations: [ | 3358 prefixExpectations: [ |
3361 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3359 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
3362 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3360 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
3363 new _PrefixExpectation(ReferenceKind.prefix, 'p'), | 3361 new _PrefixExpectation(ReferenceKind.prefix, 'p'), |
3364 ]) | 3362 ]) |
3365 ]); | 3363 ]); |
3366 } | 3364 } |
3367 | 3365 |
3368 test_constExpr_pushString_adjacent() { | 3366 test_constExpr_pushString_adjacent() { |
3369 UnlinkedVariable variable = | 3367 UnlinkedVariable variable = |
3370 serializeVariableText('const v = "aaa" "b" "ccc";'); | 3368 serializeVariableText('const v = "aaa" "b" "ccc";'); |
3371 _assertUnlinkedConst(variable.initializer.bodyExpr, | 3369 _assertUnlinkedConst(variable.initializer.bodyExpr, |
3372 operators: [UnlinkedConstOperation.pushString], strings: ['aaabccc']); | 3370 operators: [UnlinkedExprOperation.pushString], strings: ['aaabccc']); |
3373 } | 3371 } |
3374 | 3372 |
3375 test_constExpr_pushString_adjacent_interpolation() { | 3373 test_constExpr_pushString_adjacent_interpolation() { |
3376 UnlinkedVariable variable = | 3374 UnlinkedVariable variable = |
3377 serializeVariableText(r'const v = "aaa" "bb ${42} bbb" "cccc";'); | 3375 serializeVariableText(r'const v = "aaa" "bb ${42} bbb" "cccc";'); |
3378 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3376 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3379 UnlinkedConstOperation.pushString, | 3377 UnlinkedExprOperation.pushString, |
3380 UnlinkedConstOperation.pushString, | 3378 UnlinkedExprOperation.pushString, |
3381 UnlinkedConstOperation.pushInt, | 3379 UnlinkedExprOperation.pushInt, |
3382 UnlinkedConstOperation.pushString, | 3380 UnlinkedExprOperation.pushString, |
3383 UnlinkedConstOperation.concatenate, | 3381 UnlinkedExprOperation.concatenate, |
3384 UnlinkedConstOperation.pushString, | 3382 UnlinkedExprOperation.pushString, |
3385 UnlinkedConstOperation.concatenate, | 3383 UnlinkedExprOperation.concatenate, |
3386 ], ints: [ | 3384 ], ints: [ |
3387 42, | 3385 42, |
3388 3, | 3386 3, |
3389 3, | 3387 3, |
3390 ], strings: [ | 3388 ], strings: [ |
3391 'aaa', | 3389 'aaa', |
3392 'bb ', | 3390 'bb ', |
3393 ' bbb', | 3391 ' bbb', |
3394 'cccc' | 3392 'cccc' |
3395 ]); | 3393 ]); |
3396 } | 3394 } |
3397 | 3395 |
3398 test_constExpr_pushString_interpolation() { | 3396 test_constExpr_pushString_interpolation() { |
3399 UnlinkedVariable variable = | 3397 UnlinkedVariable variable = |
3400 serializeVariableText(r'const v = "aaa ${42} bbb";'); | 3398 serializeVariableText(r'const v = "aaa ${42} bbb";'); |
3401 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3399 _assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
3402 UnlinkedConstOperation.pushString, | 3400 UnlinkedExprOperation.pushString, |
3403 UnlinkedConstOperation.pushInt, | 3401 UnlinkedExprOperation.pushInt, |
3404 UnlinkedConstOperation.pushString, | 3402 UnlinkedExprOperation.pushString, |
3405 UnlinkedConstOperation.concatenate | 3403 UnlinkedExprOperation.concatenate |
3406 ], ints: [ | 3404 ], ints: [ |
3407 42, | 3405 42, |
3408 3 | 3406 3 |
3409 ], strings: [ | 3407 ], strings: [ |
3410 'aaa ', | 3408 'aaa ', |
3411 ' bbb' | 3409 ' bbb' |
3412 ]); | 3410 ]); |
3413 } | 3411 } |
3414 | 3412 |
3415 test_constExpr_pushString_simple() { | 3413 test_constExpr_pushString_simple() { |
3416 UnlinkedVariable variable = serializeVariableText('const v = "abc";'); | 3414 UnlinkedVariable variable = serializeVariableText('const v = "abc";'); |
3417 _assertUnlinkedConst(variable.initializer.bodyExpr, | 3415 _assertUnlinkedConst(variable.initializer.bodyExpr, |
3418 operators: [UnlinkedConstOperation.pushString], strings: ['abc']); | 3416 operators: [UnlinkedExprOperation.pushString], strings: ['abc']); |
3419 } | 3417 } |
3420 | 3418 |
3421 test_constExpr_pushTrue() { | 3419 test_constExpr_pushTrue() { |
3422 UnlinkedVariable variable = serializeVariableText('const v = true;'); | 3420 UnlinkedVariable variable = serializeVariableText('const v = true;'); |
3423 _assertUnlinkedConst(variable.initializer.bodyExpr, | 3421 _assertUnlinkedConst(variable.initializer.bodyExpr, |
3424 operators: [UnlinkedConstOperation.pushTrue]); | 3422 operators: [UnlinkedExprOperation.pushTrue]); |
3425 } | 3423 } |
3426 | 3424 |
3427 test_constructor() { | 3425 test_constructor() { |
3428 String text = 'class C { C(); }'; | 3426 String text = 'class C { C(); }'; |
3429 UnlinkedExecutable executable = | 3427 UnlinkedExecutable executable = |
3430 findExecutable('', executables: serializeClassText(text).executables); | 3428 findExecutable('', executables: serializeClassText(text).executables); |
3431 expect(executable.kind, UnlinkedExecutableKind.constructor); | 3429 expect(executable.kind, UnlinkedExecutableKind.constructor); |
3432 expect(executable.returnType, isNull); | 3430 expect(executable.returnType, isNull); |
3433 expect(executable.isAsynchronous, isFalse); | 3431 expect(executable.isAsynchronous, isFalse); |
3434 expect(executable.isExternal, isFalse); | 3432 expect(executable.isExternal, isFalse); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3506 final x; | 3504 final x; |
3507 const C() : x = 42; | 3505 const C() : x = 42; |
3508 } | 3506 } |
3509 ''').executables); | 3507 ''').executables); |
3510 expect(executable.constantInitializers, hasLength(1)); | 3508 expect(executable.constantInitializers, hasLength(1)); |
3511 UnlinkedConstructorInitializer initializer = | 3509 UnlinkedConstructorInitializer initializer = |
3512 executable.constantInitializers[0]; | 3510 executable.constantInitializers[0]; |
3513 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); | 3511 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); |
3514 expect(initializer.name, 'x'); | 3512 expect(initializer.name, 'x'); |
3515 _assertUnlinkedConst(initializer.expression, | 3513 _assertUnlinkedConst(initializer.expression, |
3516 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3514 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3517 expect(initializer.arguments, isEmpty); | 3515 expect(initializer.arguments, isEmpty); |
3518 } | 3516 } |
3519 | 3517 |
3520 test_constructor_initializers_field_withParameter() { | 3518 test_constructor_initializers_field_withParameter() { |
3521 UnlinkedExecutable executable = | 3519 UnlinkedExecutable executable = |
3522 findExecutable('', executables: serializeClassText(r''' | 3520 findExecutable('', executables: serializeClassText(r''' |
3523 class C { | 3521 class C { |
3524 final x; | 3522 final x; |
3525 const C(int p) : x = p; | 3523 const C(int p) : x = p; |
3526 } | 3524 } |
3527 ''').executables); | 3525 ''').executables); |
3528 expect(executable.constantInitializers, hasLength(1)); | 3526 expect(executable.constantInitializers, hasLength(1)); |
3529 UnlinkedConstructorInitializer initializer = | 3527 UnlinkedConstructorInitializer initializer = |
3530 executable.constantInitializers[0]; | 3528 executable.constantInitializers[0]; |
3531 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); | 3529 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); |
3532 expect(initializer.name, 'x'); | 3530 expect(initializer.name, 'x'); |
3533 _assertUnlinkedConst(initializer.expression, | 3531 _assertUnlinkedConst(initializer.expression, |
3534 operators: [UnlinkedConstOperation.pushParameter], strings: ['p']); | 3532 operators: [UnlinkedExprOperation.pushParameter], strings: ['p']); |
3535 expect(initializer.arguments, isEmpty); | 3533 expect(initializer.arguments, isEmpty); |
3536 } | 3534 } |
3537 | 3535 |
3538 test_constructor_initializers_notConst() { | 3536 test_constructor_initializers_notConst() { |
3539 UnlinkedExecutable executable = | 3537 UnlinkedExecutable executable = |
3540 findExecutable('', executables: serializeClassText(r''' | 3538 findExecutable('', executables: serializeClassText(r''' |
3541 class C { | 3539 class C { |
3542 final x; | 3540 final x; |
3543 C() : x = 42; | 3541 C() : x = 42; |
3544 } | 3542 } |
(...skipping 13 matching lines...) Expand all Loading... |
3558 ''').executables); | 3556 ''').executables); |
3559 expect(executable.constantInitializers, hasLength(1)); | 3557 expect(executable.constantInitializers, hasLength(1)); |
3560 UnlinkedConstructorInitializer initializer = | 3558 UnlinkedConstructorInitializer initializer = |
3561 executable.constantInitializers[0]; | 3559 executable.constantInitializers[0]; |
3562 expect( | 3560 expect( |
3563 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); | 3561 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
3564 expect(initializer.name, 'aaa'); | 3562 expect(initializer.name, 'aaa'); |
3565 expect(initializer.expression, isNull); | 3563 expect(initializer.expression, isNull); |
3566 expect(initializer.arguments, hasLength(1)); | 3564 expect(initializer.arguments, hasLength(1)); |
3567 _assertUnlinkedConst(initializer.arguments[0], | 3565 _assertUnlinkedConst(initializer.arguments[0], |
3568 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3566 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3569 } | 3567 } |
3570 | 3568 |
3571 test_constructor_initializers_superInvocation_namedExpression() { | 3569 test_constructor_initializers_superInvocation_namedExpression() { |
3572 UnlinkedExecutable executable = | 3570 UnlinkedExecutable executable = |
3573 findExecutable('', executables: serializeClassText(r''' | 3571 findExecutable('', executables: serializeClassText(r''' |
3574 class A { | 3572 class A { |
3575 const A(a, {int b, int c}); | 3573 const A(a, {int b, int c}); |
3576 } | 3574 } |
3577 class C extends A { | 3575 class C extends A { |
3578 const C() : super(1, b: 2, c: 3); | 3576 const C() : super(1, b: 2, c: 3); |
3579 } | 3577 } |
3580 ''').executables); | 3578 ''').executables); |
3581 expect(executable.constantInitializers, hasLength(1)); | 3579 expect(executable.constantInitializers, hasLength(1)); |
3582 UnlinkedConstructorInitializer initializer = | 3580 UnlinkedConstructorInitializer initializer = |
3583 executable.constantInitializers[0]; | 3581 executable.constantInitializers[0]; |
3584 expect( | 3582 expect( |
3585 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); | 3583 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
3586 expect(initializer.name, ''); | 3584 expect(initializer.name, ''); |
3587 expect(initializer.expression, isNull); | 3585 expect(initializer.expression, isNull); |
3588 expect(initializer.arguments, hasLength(3)); | 3586 expect(initializer.arguments, hasLength(3)); |
3589 _assertUnlinkedConst(initializer.arguments[0], | 3587 _assertUnlinkedConst(initializer.arguments[0], |
3590 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3588 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
3591 _assertUnlinkedConst(initializer.arguments[1], | 3589 _assertUnlinkedConst(initializer.arguments[1], |
3592 operators: [UnlinkedConstOperation.pushInt], ints: [2]); | 3590 operators: [UnlinkedExprOperation.pushInt], ints: [2]); |
3593 _assertUnlinkedConst(initializer.arguments[2], | 3591 _assertUnlinkedConst(initializer.arguments[2], |
3594 operators: [UnlinkedConstOperation.pushInt], ints: [3]); | 3592 operators: [UnlinkedExprOperation.pushInt], ints: [3]); |
3595 expect(initializer.argumentNames, ['b', 'c']); | 3593 expect(initializer.argumentNames, ['b', 'c']); |
3596 } | 3594 } |
3597 | 3595 |
3598 test_constructor_initializers_superInvocation_unnamed() { | 3596 test_constructor_initializers_superInvocation_unnamed() { |
3599 UnlinkedExecutable executable = | 3597 UnlinkedExecutable executable = |
3600 findExecutable('ccc', executables: serializeClassText(r''' | 3598 findExecutable('ccc', executables: serializeClassText(r''' |
3601 class A { | 3599 class A { |
3602 const A(int p); | 3600 const A(int p); |
3603 } | 3601 } |
3604 class C extends A { | 3602 class C extends A { |
3605 const C.ccc() : super(42); | 3603 const C.ccc() : super(42); |
3606 } | 3604 } |
3607 ''').executables); | 3605 ''').executables); |
3608 expect(executable.constantInitializers, hasLength(1)); | 3606 expect(executable.constantInitializers, hasLength(1)); |
3609 UnlinkedConstructorInitializer initializer = | 3607 UnlinkedConstructorInitializer initializer = |
3610 executable.constantInitializers[0]; | 3608 executable.constantInitializers[0]; |
3611 expect( | 3609 expect( |
3612 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); | 3610 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
3613 expect(initializer.name, ''); | 3611 expect(initializer.name, ''); |
3614 expect(initializer.expression, isNull); | 3612 expect(initializer.expression, isNull); |
3615 expect(initializer.arguments, hasLength(1)); | 3613 expect(initializer.arguments, hasLength(1)); |
3616 _assertUnlinkedConst(initializer.arguments[0], | 3614 _assertUnlinkedConst(initializer.arguments[0], |
3617 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3615 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3618 } | 3616 } |
3619 | 3617 |
3620 test_constructor_initializers_thisInvocation_named() { | 3618 test_constructor_initializers_thisInvocation_named() { |
3621 UnlinkedExecutable executable = | 3619 UnlinkedExecutable executable = |
3622 findExecutable('', executables: serializeClassText(r''' | 3620 findExecutable('', executables: serializeClassText(r''' |
3623 class C { | 3621 class C { |
3624 const C() : this.named(1, 'bbb'); | 3622 const C() : this.named(1, 'bbb'); |
3625 const C.named(int a, String b); | 3623 const C.named(int a, String b); |
3626 } | 3624 } |
3627 ''').executables); | 3625 ''').executables); |
3628 expect(executable.constantInitializers, hasLength(1)); | 3626 expect(executable.constantInitializers, hasLength(1)); |
3629 UnlinkedConstructorInitializer initializer = | 3627 UnlinkedConstructorInitializer initializer = |
3630 executable.constantInitializers[0]; | 3628 executable.constantInitializers[0]; |
3631 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3629 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
3632 expect(initializer.name, 'named'); | 3630 expect(initializer.name, 'named'); |
3633 expect(initializer.expression, isNull); | 3631 expect(initializer.expression, isNull); |
3634 expect(initializer.arguments, hasLength(2)); | 3632 expect(initializer.arguments, hasLength(2)); |
3635 _assertUnlinkedConst(initializer.arguments[0], | 3633 _assertUnlinkedConst(initializer.arguments[0], |
3636 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3634 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
3637 _assertUnlinkedConst(initializer.arguments[1], | 3635 _assertUnlinkedConst(initializer.arguments[1], |
3638 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); | 3636 operators: [UnlinkedExprOperation.pushString], strings: ['bbb']); |
3639 } | 3637 } |
3640 | 3638 |
3641 test_constructor_initializers_thisInvocation_namedExpression() { | 3639 test_constructor_initializers_thisInvocation_namedExpression() { |
3642 UnlinkedExecutable executable = | 3640 UnlinkedExecutable executable = |
3643 findExecutable('', executables: serializeClassText(r''' | 3641 findExecutable('', executables: serializeClassText(r''' |
3644 class C { | 3642 class C { |
3645 const C() : this.named(1, b: 2, c: 3); | 3643 const C() : this.named(1, b: 2, c: 3); |
3646 const C.named(a, {int b, int c}); | 3644 const C.named(a, {int b, int c}); |
3647 } | 3645 } |
3648 ''').executables); | 3646 ''').executables); |
3649 expect(executable.constantInitializers, hasLength(1)); | 3647 expect(executable.constantInitializers, hasLength(1)); |
3650 UnlinkedConstructorInitializer initializer = | 3648 UnlinkedConstructorInitializer initializer = |
3651 executable.constantInitializers[0]; | 3649 executable.constantInitializers[0]; |
3652 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3650 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
3653 expect(initializer.name, 'named'); | 3651 expect(initializer.name, 'named'); |
3654 expect(initializer.expression, isNull); | 3652 expect(initializer.expression, isNull); |
3655 expect(initializer.arguments, hasLength(3)); | 3653 expect(initializer.arguments, hasLength(3)); |
3656 _assertUnlinkedConst(initializer.arguments[0], | 3654 _assertUnlinkedConst(initializer.arguments[0], |
3657 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3655 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
3658 _assertUnlinkedConst(initializer.arguments[1], | 3656 _assertUnlinkedConst(initializer.arguments[1], |
3659 operators: [UnlinkedConstOperation.pushInt], ints: [2]); | 3657 operators: [UnlinkedExprOperation.pushInt], ints: [2]); |
3660 _assertUnlinkedConst(initializer.arguments[2], | 3658 _assertUnlinkedConst(initializer.arguments[2], |
3661 operators: [UnlinkedConstOperation.pushInt], ints: [3]); | 3659 operators: [UnlinkedExprOperation.pushInt], ints: [3]); |
3662 expect(initializer.argumentNames, ['b', 'c']); | 3660 expect(initializer.argumentNames, ['b', 'c']); |
3663 } | 3661 } |
3664 | 3662 |
3665 test_constructor_initializers_thisInvocation_unnamed() { | 3663 test_constructor_initializers_thisInvocation_unnamed() { |
3666 UnlinkedExecutable executable = | 3664 UnlinkedExecutable executable = |
3667 findExecutable('named', executables: serializeClassText(r''' | 3665 findExecutable('named', executables: serializeClassText(r''' |
3668 class C { | 3666 class C { |
3669 const C.named() : this(1, 'bbb'); | 3667 const C.named() : this(1, 'bbb'); |
3670 const C(int a, String b); | 3668 const C(int a, String b); |
3671 } | 3669 } |
3672 ''').executables); | 3670 ''').executables); |
3673 expect(executable.constantInitializers, hasLength(1)); | 3671 expect(executable.constantInitializers, hasLength(1)); |
3674 UnlinkedConstructorInitializer initializer = | 3672 UnlinkedConstructorInitializer initializer = |
3675 executable.constantInitializers[0]; | 3673 executable.constantInitializers[0]; |
3676 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3674 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
3677 expect(initializer.name, ''); | 3675 expect(initializer.name, ''); |
3678 expect(initializer.expression, isNull); | 3676 expect(initializer.expression, isNull); |
3679 expect(initializer.arguments, hasLength(2)); | 3677 expect(initializer.arguments, hasLength(2)); |
3680 _assertUnlinkedConst(initializer.arguments[0], | 3678 _assertUnlinkedConst(initializer.arguments[0], |
3681 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3679 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
3682 _assertUnlinkedConst(initializer.arguments[1], | 3680 _assertUnlinkedConst(initializer.arguments[1], |
3683 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); | 3681 operators: [UnlinkedExprOperation.pushString], strings: ['bbb']); |
3684 } | 3682 } |
3685 | 3683 |
3686 test_constructor_initializing_formal() { | 3684 test_constructor_initializing_formal() { |
3687 UnlinkedExecutable executable = findExecutable('', | 3685 UnlinkedExecutable executable = findExecutable('', |
3688 executables: | 3686 executables: |
3689 serializeClassText('class C { C(this.x); final x; }').executables); | 3687 serializeClassText('class C { C(this.x); final x; }').executables); |
3690 UnlinkedParam parameter = executable.parameters[0]; | 3688 UnlinkedParam parameter = executable.parameters[0]; |
3691 expect(parameter.isInitializingFormal, isTrue); | 3689 expect(parameter.isInitializingFormal, isTrue); |
3692 } | 3690 } |
3693 | 3691 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3758 C([this.x() = foo]); | 3756 C([this.x() = foo]); |
3759 final x; | 3757 final x; |
3760 } | 3758 } |
3761 int foo() => 0; | 3759 int foo() => 0; |
3762 ''').executables); | 3760 ''').executables); |
3763 UnlinkedParam param = executable.parameters[0]; | 3761 UnlinkedParam param = executable.parameters[0]; |
3764 expect(param.isFunctionTyped, isTrue); | 3762 expect(param.isFunctionTyped, isTrue); |
3765 expect(param.kind, UnlinkedParamKind.positional); | 3763 expect(param.kind, UnlinkedParamKind.positional); |
3766 expect(param.defaultValueCode, 'foo'); | 3764 expect(param.defaultValueCode, 'foo'); |
3767 _assertUnlinkedConst(param.initializer.bodyExpr, operators: [ | 3765 _assertUnlinkedConst(param.initializer.bodyExpr, operators: [ |
3768 UnlinkedConstOperation.pushReference | 3766 UnlinkedExprOperation.pushReference |
3769 ], referenceValidators: [ | 3767 ], referenceValidators: [ |
3770 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3768 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
3771 expectedKind: ReferenceKind.topLevelFunction) | 3769 expectedKind: ReferenceKind.topLevelFunction) |
3772 ]); | 3770 ]); |
3773 } | 3771 } |
3774 | 3772 |
3775 test_constructor_initializing_formal_implicit_type() { | 3773 test_constructor_initializing_formal_implicit_type() { |
3776 // Note: the implicit type of an initializing formal is the type of the | 3774 // Note: the implicit type of an initializing formal is the type of the |
3777 // field. | 3775 // field. |
3778 UnlinkedExecutable executable = findExecutable('', | 3776 UnlinkedExecutable executable = findExecutable('', |
(...skipping 24 matching lines...) Expand all Loading... |
3803 test_constructor_initializing_formal_named_withDefault() { | 3801 test_constructor_initializing_formal_named_withDefault() { |
3804 UnlinkedExecutable executable = findExecutable('', | 3802 UnlinkedExecutable executable = findExecutable('', |
3805 executables: serializeClassText('class C { C({this.x: 42}); final x; }') | 3803 executables: serializeClassText('class C { C({this.x: 42}); final x; }') |
3806 .executables); | 3804 .executables); |
3807 UnlinkedParam parameter = executable.parameters[0]; | 3805 UnlinkedParam parameter = executable.parameters[0]; |
3808 expect(parameter.kind, UnlinkedParamKind.named); | 3806 expect(parameter.kind, UnlinkedParamKind.named); |
3809 expect(parameter.initializer, isNotNull); | 3807 expect(parameter.initializer, isNotNull); |
3810 expect(parameter.defaultValueCode, '42'); | 3808 expect(parameter.defaultValueCode, '42'); |
3811 _assertCodeRange(parameter.codeRange, 13, 10); | 3809 _assertCodeRange(parameter.codeRange, 13, 10); |
3812 _assertUnlinkedConst(parameter.initializer.bodyExpr, | 3810 _assertUnlinkedConst(parameter.initializer.bodyExpr, |
3813 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3811 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3814 } | 3812 } |
3815 | 3813 |
3816 test_constructor_initializing_formal_non_function_typed() { | 3814 test_constructor_initializing_formal_non_function_typed() { |
3817 UnlinkedExecutable executable = findExecutable('', | 3815 UnlinkedExecutable executable = findExecutable('', |
3818 executables: | 3816 executables: |
3819 serializeClassText('class C { C(this.x); final x; }').executables); | 3817 serializeClassText('class C { C(this.x); final x; }').executables); |
3820 UnlinkedParam parameter = executable.parameters[0]; | 3818 UnlinkedParam parameter = executable.parameters[0]; |
3821 expect(parameter.isFunctionTyped, isFalse); | 3819 expect(parameter.isFunctionTyped, isFalse); |
3822 } | 3820 } |
3823 | 3821 |
(...skipping 11 matching lines...) Expand all Loading... |
3835 UnlinkedExecutable executable = findExecutable('', | 3833 UnlinkedExecutable executable = findExecutable('', |
3836 executables: | 3834 executables: |
3837 serializeClassText('class C { C([this.x = 42]); final x; }') | 3835 serializeClassText('class C { C([this.x = 42]); final x; }') |
3838 .executables); | 3836 .executables); |
3839 UnlinkedParam parameter = executable.parameters[0]; | 3837 UnlinkedParam parameter = executable.parameters[0]; |
3840 expect(parameter.kind, UnlinkedParamKind.positional); | 3838 expect(parameter.kind, UnlinkedParamKind.positional); |
3841 expect(parameter.initializer, isNotNull); | 3839 expect(parameter.initializer, isNotNull); |
3842 expect(parameter.defaultValueCode, '42'); | 3840 expect(parameter.defaultValueCode, '42'); |
3843 _assertCodeRange(parameter.codeRange, 13, 11); | 3841 _assertCodeRange(parameter.codeRange, 13, 11); |
3844 _assertUnlinkedConst(parameter.initializer.bodyExpr, | 3842 _assertUnlinkedConst(parameter.initializer.bodyExpr, |
3845 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3843 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3846 } | 3844 } |
3847 | 3845 |
3848 test_constructor_initializing_formal_required() { | 3846 test_constructor_initializing_formal_required() { |
3849 UnlinkedExecutable executable = findExecutable('', | 3847 UnlinkedExecutable executable = findExecutable('', |
3850 executables: | 3848 executables: |
3851 serializeClassText('class C { C(this.x); final x; }').executables); | 3849 serializeClassText('class C { C(this.x); final x; }').executables); |
3852 UnlinkedParam parameter = executable.parameters[0]; | 3850 UnlinkedParam parameter = executable.parameters[0]; |
3853 expect(parameter.kind, UnlinkedParamKind.required); | 3851 expect(parameter.kind, UnlinkedParamKind.required); |
3854 } | 3852 } |
3855 | 3853 |
(...skipping 11 matching lines...) Expand all Loading... |
3867 UnlinkedExecutable executable = | 3865 UnlinkedExecutable executable = |
3868 findExecutable('', executables: serializeClassText(r''' | 3866 findExecutable('', executables: serializeClassText(r''' |
3869 class C { | 3867 class C { |
3870 C([this.x = 42]); | 3868 C([this.x = 42]); |
3871 final int x; | 3869 final int x; |
3872 }''').executables); | 3870 }''').executables); |
3873 UnlinkedParam param = executable.parameters[0]; | 3871 UnlinkedParam param = executable.parameters[0]; |
3874 expect(param.kind, UnlinkedParamKind.positional); | 3872 expect(param.kind, UnlinkedParamKind.positional); |
3875 expect(param.defaultValueCode, '42'); | 3873 expect(param.defaultValueCode, '42'); |
3876 _assertUnlinkedConst(param.initializer.bodyExpr, | 3874 _assertUnlinkedConst(param.initializer.bodyExpr, |
3877 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 3875 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
3878 } | 3876 } |
3879 | 3877 |
3880 test_constructor_named() { | 3878 test_constructor_named() { |
3881 String text = 'class C { C.foo(); }'; | 3879 String text = 'class C { C.foo(); }'; |
3882 UnlinkedExecutable executable = findExecutable('foo', | 3880 UnlinkedExecutable executable = findExecutable('foo', |
3883 executables: serializeClassText(text).executables); | 3881 executables: serializeClassText(text).executables); |
3884 expect(executable.name, 'foo'); | 3882 expect(executable.name, 'foo'); |
3885 expect(executable.nameOffset, text.indexOf('foo')); | 3883 expect(executable.nameOffset, text.indexOf('foo')); |
3886 expect(executable.periodOffset, text.indexOf('.foo')); | 3884 expect(executable.periodOffset, text.indexOf('.foo')); |
3887 expect(executable.nameEnd, text.indexOf('()')); | 3885 expect(executable.nameEnd, text.indexOf('()')); |
(...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5777 test_executable_param_function_typed_withDefault() { | 5775 test_executable_param_function_typed_withDefault() { |
5778 UnlinkedExecutable executable = serializeExecutableText(r''' | 5776 UnlinkedExecutable executable = serializeExecutableText(r''' |
5779 f([int p(int a2, String b2) = foo]) {} | 5777 f([int p(int a2, String b2) = foo]) {} |
5780 int foo(int a, String b) => 0; | 5778 int foo(int a, String b) => 0; |
5781 '''); | 5779 '''); |
5782 UnlinkedParam param = executable.parameters[0]; | 5780 UnlinkedParam param = executable.parameters[0]; |
5783 expect(param.kind, UnlinkedParamKind.positional); | 5781 expect(param.kind, UnlinkedParamKind.positional); |
5784 expect(param.initializer, isNotNull); | 5782 expect(param.initializer, isNotNull); |
5785 expect(param.defaultValueCode, 'foo'); | 5783 expect(param.defaultValueCode, 'foo'); |
5786 _assertUnlinkedConst(param.initializer.bodyExpr, operators: [ | 5784 _assertUnlinkedConst(param.initializer.bodyExpr, operators: [ |
5787 UnlinkedConstOperation.pushReference | 5785 UnlinkedExprOperation.pushReference |
5788 ], referenceValidators: [ | 5786 ], referenceValidators: [ |
5789 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 5787 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
5790 expectedKind: ReferenceKind.topLevelFunction) | 5788 expectedKind: ReferenceKind.topLevelFunction) |
5791 ]); | 5789 ]); |
5792 } | 5790 } |
5793 | 5791 |
5794 test_executable_param_kind_named() { | 5792 test_executable_param_kind_named() { |
5795 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); | 5793 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); |
5796 UnlinkedParam param = executable.parameters[0]; | 5794 UnlinkedParam param = executable.parameters[0]; |
5797 expect(param.kind, UnlinkedParamKind.named); | 5795 expect(param.kind, UnlinkedParamKind.named); |
5798 expect(param.initializer, isNull); | 5796 expect(param.initializer, isNull); |
5799 expect(param.defaultValueCode, isEmpty); | 5797 expect(param.defaultValueCode, isEmpty); |
5800 } | 5798 } |
5801 | 5799 |
5802 test_executable_param_kind_named_withDefault() { | 5800 test_executable_param_kind_named_withDefault() { |
5803 UnlinkedExecutable executable = serializeExecutableText('f({x: 42}) {}'); | 5801 UnlinkedExecutable executable = serializeExecutableText('f({x: 42}) {}'); |
5804 UnlinkedParam param = executable.parameters[0]; | 5802 UnlinkedParam param = executable.parameters[0]; |
5805 expect(param.kind, UnlinkedParamKind.named); | 5803 expect(param.kind, UnlinkedParamKind.named); |
5806 expect(param.initializer, isNotNull); | 5804 expect(param.initializer, isNotNull); |
5807 expect(param.defaultValueCode, '42'); | 5805 expect(param.defaultValueCode, '42'); |
5808 _assertCodeRange(param.codeRange, 3, 5); | 5806 _assertCodeRange(param.codeRange, 3, 5); |
5809 _assertUnlinkedConst(param.initializer.bodyExpr, | 5807 _assertUnlinkedConst(param.initializer.bodyExpr, |
5810 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 5808 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
5811 } | 5809 } |
5812 | 5810 |
5813 test_executable_param_kind_positional() { | 5811 test_executable_param_kind_positional() { |
5814 UnlinkedExecutable executable = serializeExecutableText('f([x]) {}'); | 5812 UnlinkedExecutable executable = serializeExecutableText('f([x]) {}'); |
5815 UnlinkedParam param = executable.parameters[0]; | 5813 UnlinkedParam param = executable.parameters[0]; |
5816 expect(param.kind, UnlinkedParamKind.positional); | 5814 expect(param.kind, UnlinkedParamKind.positional); |
5817 expect(param.initializer, isNull); | 5815 expect(param.initializer, isNull); |
5818 expect(param.defaultValueCode, isEmpty); | 5816 expect(param.defaultValueCode, isEmpty); |
5819 } | 5817 } |
5820 | 5818 |
5821 test_executable_param_kind_positional_withDefault() { | 5819 test_executable_param_kind_positional_withDefault() { |
5822 UnlinkedExecutable executable = serializeExecutableText('f([x = 42]) {}'); | 5820 UnlinkedExecutable executable = serializeExecutableText('f([x = 42]) {}'); |
5823 UnlinkedParam param = executable.parameters[0]; | 5821 UnlinkedParam param = executable.parameters[0]; |
5824 expect(param.kind, UnlinkedParamKind.positional); | 5822 expect(param.kind, UnlinkedParamKind.positional); |
5825 expect(param.initializer, isNotNull); | 5823 expect(param.initializer, isNotNull); |
5826 expect(param.defaultValueCode, '42'); | 5824 expect(param.defaultValueCode, '42'); |
5827 _assertCodeRange(param.codeRange, 3, 6); | 5825 _assertCodeRange(param.codeRange, 3, 6); |
5828 _assertUnlinkedConst(param.initializer.bodyExpr, | 5826 _assertUnlinkedConst(param.initializer.bodyExpr, |
5829 operators: [UnlinkedConstOperation.pushInt], ints: [42]); | 5827 operators: [UnlinkedExprOperation.pushInt], ints: [42]); |
5830 } | 5828 } |
5831 | 5829 |
5832 test_executable_param_kind_required() { | 5830 test_executable_param_kind_required() { |
5833 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); | 5831 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); |
5834 UnlinkedParam param = executable.parameters[0]; | 5832 UnlinkedParam param = executable.parameters[0]; |
5835 expect(param.kind, UnlinkedParamKind.required); | 5833 expect(param.kind, UnlinkedParamKind.required); |
5836 expect(param.initializer, isNull); | 5834 expect(param.initializer, isNull); |
5837 expect(param.defaultValueCode, isEmpty); | 5835 expect(param.defaultValueCode, isEmpty); |
5838 } | 5836 } |
5839 | 5837 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6383 } | 6381 } |
6384 class C { | 6382 class C { |
6385 List<int> f = <int>[0, 1, 2]; | 6383 List<int> f = <int>[0, 1, 2]; |
6386 } | 6384 } |
6387 A a = new A(); | 6385 A a = new A(); |
6388 final v = (a.b.c.f[1] = 5); | 6386 final v = (a.b.c.f[1] = 5); |
6389 '''); | 6387 '''); |
6390 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6388 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6391 isValidConst: false, | 6389 isValidConst: false, |
6392 operators: [ | 6390 operators: [ |
6393 UnlinkedConstOperation.pushInt, | 6391 UnlinkedExprOperation.pushInt, |
6394 UnlinkedConstOperation.pushReference, | 6392 UnlinkedExprOperation.pushReference, |
6395 UnlinkedConstOperation.pushInt, | 6393 UnlinkedExprOperation.pushInt, |
6396 UnlinkedConstOperation.assignToIndex, | 6394 UnlinkedExprOperation.assignToIndex, |
6397 ], | 6395 ], |
6398 assignmentOperators: [ | 6396 assignmentOperators: [ |
6399 (UnlinkedExprAssignOperator.assign) | 6397 (UnlinkedExprAssignOperator.assign) |
6400 ], | 6398 ], |
6401 ints: [ | 6399 ints: [ |
6402 5, | 6400 5, |
6403 1 | 6401 1 |
6404 ], | 6402 ], |
6405 strings: [], | 6403 strings: [], |
6406 referenceValidators: [ | 6404 referenceValidators: [ |
(...skipping 22 matching lines...) Expand all Loading... |
6429 class C { | 6427 class C { |
6430 List<int> f = <int>[0, 1, 2]; | 6428 List<int> f = <int>[0, 1, 2]; |
6431 } | 6429 } |
6432 A a = new A(); | 6430 A a = new A(); |
6433 final v = (a.b[1].c[2].f[3] = 5); | 6431 final v = (a.b[1].c[2].f[3] = 5); |
6434 '''); | 6432 '''); |
6435 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6433 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6436 isValidConst: false, | 6434 isValidConst: false, |
6437 operators: [ | 6435 operators: [ |
6438 // 5 | 6436 // 5 |
6439 UnlinkedConstOperation.pushInt, | 6437 UnlinkedExprOperation.pushInt, |
6440 // a.b[1] | 6438 // a.b[1] |
6441 UnlinkedConstOperation.pushReference, | 6439 UnlinkedExprOperation.pushReference, |
6442 UnlinkedConstOperation.pushInt, | 6440 UnlinkedExprOperation.pushInt, |
6443 UnlinkedConstOperation.extractIndex, | 6441 UnlinkedExprOperation.extractIndex, |
6444 // c[2] | 6442 // c[2] |
6445 UnlinkedConstOperation.extractProperty, | 6443 UnlinkedExprOperation.extractProperty, |
6446 UnlinkedConstOperation.pushInt, | 6444 UnlinkedExprOperation.pushInt, |
6447 UnlinkedConstOperation.extractIndex, | 6445 UnlinkedExprOperation.extractIndex, |
6448 // f[3] = 5 | 6446 // f[3] = 5 |
6449 UnlinkedConstOperation.extractProperty, | 6447 UnlinkedExprOperation.extractProperty, |
6450 UnlinkedConstOperation.pushInt, | 6448 UnlinkedExprOperation.pushInt, |
6451 UnlinkedConstOperation.assignToIndex, | 6449 UnlinkedExprOperation.assignToIndex, |
6452 ], | 6450 ], |
6453 assignmentOperators: [ | 6451 assignmentOperators: [ |
6454 (UnlinkedExprAssignOperator.assign) | 6452 (UnlinkedExprAssignOperator.assign) |
6455 ], | 6453 ], |
6456 ints: [ | 6454 ints: [ |
6457 5, | 6455 5, |
6458 1, | 6456 1, |
6459 2, | 6457 2, |
6460 3, | 6458 3, |
6461 ], | 6459 ], |
(...skipping 15 matching lines...) Expand all Loading... |
6477 if (skipNonConstInitializers) { | 6475 if (skipNonConstInitializers) { |
6478 return; | 6476 return; |
6479 } | 6477 } |
6480 UnlinkedVariable variable = serializeVariableText(''' | 6478 UnlinkedVariable variable = serializeVariableText(''' |
6481 List<int> a = <int>[0, 1, 2]; | 6479 List<int> a = <int>[0, 1, 2]; |
6482 final v = (a[1] = 5); | 6480 final v = (a[1] = 5); |
6483 '''); | 6481 '''); |
6484 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6482 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6485 isValidConst: false, | 6483 isValidConst: false, |
6486 operators: [ | 6484 operators: [ |
6487 UnlinkedConstOperation.pushInt, | 6485 UnlinkedExprOperation.pushInt, |
6488 UnlinkedConstOperation.pushReference, | 6486 UnlinkedExprOperation.pushReference, |
6489 UnlinkedConstOperation.pushInt, | 6487 UnlinkedExprOperation.pushInt, |
6490 UnlinkedConstOperation.assignToIndex, | 6488 UnlinkedExprOperation.assignToIndex, |
6491 ], | 6489 ], |
6492 assignmentOperators: [ | 6490 assignmentOperators: [ |
6493 (UnlinkedExprAssignOperator.assign) | 6491 (UnlinkedExprAssignOperator.assign) |
6494 ], | 6492 ], |
6495 ints: [ | 6493 ints: [ |
6496 5, | 6494 5, |
6497 1, | 6495 1, |
6498 ], | 6496 ], |
6499 strings: [], | 6497 strings: [], |
6500 referenceValidators: [ | 6498 referenceValidators: [ |
6501 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6499 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
6502 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6500 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
6503 ]); | 6501 ]); |
6504 } | 6502 } |
6505 | 6503 |
6506 test_expr_assignToProperty_ofInstanceCreation() { | 6504 test_expr_assignToProperty_ofInstanceCreation() { |
6507 if (skipNonConstInitializers) { | 6505 if (skipNonConstInitializers) { |
6508 return; | 6506 return; |
6509 } | 6507 } |
6510 UnlinkedVariable variable = serializeVariableText(''' | 6508 UnlinkedVariable variable = serializeVariableText(''' |
6511 class C { | 6509 class C { |
6512 int f; | 6510 int f; |
6513 } | 6511 } |
6514 final v = (new C().f = 5); | 6512 final v = (new C().f = 5); |
6515 '''); | 6513 '''); |
6516 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6514 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6517 isValidConst: false, | 6515 isValidConst: false, |
6518 operators: [ | 6516 operators: [ |
6519 UnlinkedConstOperation.pushInt, | 6517 UnlinkedExprOperation.pushInt, |
6520 UnlinkedConstOperation.invokeConstructor, | 6518 UnlinkedExprOperation.invokeConstructor, |
6521 UnlinkedConstOperation.assignToProperty, | 6519 UnlinkedExprOperation.assignToProperty, |
6522 ], | 6520 ], |
6523 assignmentOperators: [ | 6521 assignmentOperators: [ |
6524 (UnlinkedExprAssignOperator.assign) | 6522 (UnlinkedExprAssignOperator.assign) |
6525 ], | 6523 ], |
6526 ints: [ | 6524 ints: [ |
6527 5, | 6525 5, |
6528 0, | 6526 0, |
6529 0, | 6527 0, |
6530 ], | 6528 ], |
6531 strings: [ | 6529 strings: [ |
(...skipping 11 matching lines...) Expand all Loading... |
6543 } | 6541 } |
6544 UnlinkedVariable variable = serializeVariableText(''' | 6542 UnlinkedVariable variable = serializeVariableText(''' |
6545 class C { | 6543 class C { |
6546 static int f; | 6544 static int f; |
6547 } | 6545 } |
6548 final v = (C.f = 1); | 6546 final v = (C.f = 1); |
6549 '''); | 6547 '''); |
6550 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6548 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6551 isValidConst: false, | 6549 isValidConst: false, |
6552 operators: [ | 6550 operators: [ |
6553 UnlinkedConstOperation.pushInt, | 6551 UnlinkedExprOperation.pushInt, |
6554 UnlinkedConstOperation.assignToRef, | 6552 UnlinkedExprOperation.assignToRef, |
6555 ], | 6553 ], |
6556 assignmentOperators: [ | 6554 assignmentOperators: [ |
6557 (UnlinkedExprAssignOperator.assign) | 6555 (UnlinkedExprAssignOperator.assign) |
6558 ], | 6556 ], |
6559 ints: [ | 6557 ints: [ |
6560 1, | 6558 1, |
6561 ], | 6559 ], |
6562 strings: [], | 6560 strings: [], |
6563 referenceValidators: [ | 6561 referenceValidators: [ |
6564 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6562 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
(...skipping 17 matching lines...) Expand all Loading... |
6582 } | 6580 } |
6583 class C { | 6581 class C { |
6584 int f; | 6582 int f; |
6585 } | 6583 } |
6586 A a = new A(); | 6584 A a = new A(); |
6587 final v = (a.b.c.f = 1); | 6585 final v = (a.b.c.f = 1); |
6588 '''); | 6586 '''); |
6589 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6587 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6590 isValidConst: false, | 6588 isValidConst: false, |
6591 operators: [ | 6589 operators: [ |
6592 UnlinkedConstOperation.pushInt, | 6590 UnlinkedExprOperation.pushInt, |
6593 UnlinkedConstOperation.assignToRef, | 6591 UnlinkedExprOperation.assignToRef, |
6594 ], | 6592 ], |
6595 assignmentOperators: [ | 6593 assignmentOperators: [ |
6596 (UnlinkedExprAssignOperator.assign) | 6594 (UnlinkedExprAssignOperator.assign) |
6597 ], | 6595 ], |
6598 ints: [ | 6596 ints: [ |
6599 1, | 6597 1, |
6600 ], | 6598 ], |
6601 strings: [], | 6599 strings: [], |
6602 referenceValidators: [ | 6600 referenceValidators: [ |
6603 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6601 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6635 if (skipNonConstInitializers) { | 6633 if (skipNonConstInitializers) { |
6636 return; | 6634 return; |
6637 } | 6635 } |
6638 UnlinkedVariable variable = serializeVariableText(''' | 6636 UnlinkedVariable variable = serializeVariableText(''' |
6639 int a = 0; | 6637 int a = 0; |
6640 final v = (a = 1); | 6638 final v = (a = 1); |
6641 '''); | 6639 '''); |
6642 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6640 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6643 isValidConst: false, | 6641 isValidConst: false, |
6644 operators: [ | 6642 operators: [ |
6645 UnlinkedConstOperation.pushInt, | 6643 UnlinkedExprOperation.pushInt, |
6646 UnlinkedConstOperation.assignToRef, | 6644 UnlinkedExprOperation.assignToRef, |
6647 ], | 6645 ], |
6648 assignmentOperators: [ | 6646 assignmentOperators: [ |
6649 (UnlinkedExprAssignOperator.assign) | 6647 (UnlinkedExprAssignOperator.assign) |
6650 ], | 6648 ], |
6651 ints: [ | 6649 ints: [ |
6652 1, | 6650 1, |
6653 ], | 6651 ], |
6654 strings: [], | 6652 strings: [], |
6655 referenceValidators: [ | 6653 referenceValidators: [ |
6656 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6654 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
(...skipping 10 matching lines...) Expand all Loading... |
6667 ''' | 6665 ''' |
6668 int a = 0; | 6666 int a = 0; |
6669 '''); | 6667 '''); |
6670 UnlinkedVariable variable = serializeVariableText(''' | 6668 UnlinkedVariable variable = serializeVariableText(''' |
6671 import 'a.dart'; | 6669 import 'a.dart'; |
6672 final v = (a = 1); | 6670 final v = (a = 1); |
6673 '''); | 6671 '''); |
6674 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6672 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6675 isValidConst: false, | 6673 isValidConst: false, |
6676 operators: [ | 6674 operators: [ |
6677 UnlinkedConstOperation.pushInt, | 6675 UnlinkedExprOperation.pushInt, |
6678 UnlinkedConstOperation.assignToRef, | 6676 UnlinkedExprOperation.assignToRef, |
6679 ], | 6677 ], |
6680 assignmentOperators: [ | 6678 assignmentOperators: [ |
6681 (UnlinkedExprAssignOperator.assign) | 6679 (UnlinkedExprAssignOperator.assign) |
6682 ], | 6680 ], |
6683 ints: [ | 6681 ints: [ |
6684 1, | 6682 1, |
6685 ], | 6683 ], |
6686 strings: [], | 6684 strings: [], |
6687 referenceValidators: [ | 6685 referenceValidators: [ |
6688 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 6686 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
(...skipping 10 matching lines...) Expand all Loading... |
6699 ''' | 6697 ''' |
6700 int a = 0; | 6698 int a = 0; |
6701 '''); | 6699 '''); |
6702 UnlinkedVariable variable = serializeVariableText(''' | 6700 UnlinkedVariable variable = serializeVariableText(''' |
6703 import 'a.dart' as p; | 6701 import 'a.dart' as p; |
6704 final v = (p.a = 1); | 6702 final v = (p.a = 1); |
6705 '''); | 6703 '''); |
6706 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6704 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6707 isValidConst: false, | 6705 isValidConst: false, |
6708 operators: [ | 6706 operators: [ |
6709 UnlinkedConstOperation.pushInt, | 6707 UnlinkedExprOperation.pushInt, |
6710 UnlinkedConstOperation.assignToRef, | 6708 UnlinkedExprOperation.assignToRef, |
6711 ], | 6709 ], |
6712 assignmentOperators: [ | 6710 assignmentOperators: [ |
6713 (UnlinkedExprAssignOperator.assign) | 6711 (UnlinkedExprAssignOperator.assign) |
6714 ], | 6712 ], |
6715 ints: [ | 6713 ints: [ |
6716 1, | 6714 1, |
6717 ], | 6715 ], |
6718 strings: [], | 6716 strings: [], |
6719 referenceValidators: [ | 6717 referenceValidators: [ |
6720 (EntityRef r) { | 6718 (EntityRef r) { |
(...skipping 11 matching lines...) Expand all Loading... |
6732 UnlinkedVariable variable = serializeVariableText(''' | 6730 UnlinkedVariable variable = serializeVariableText(''' |
6733 class C { | 6731 class C { |
6734 List<int> items; | 6732 List<int> items; |
6735 } | 6733 } |
6736 final C c = new C(); | 6734 final C c = new C(); |
6737 final v = c.items..[1] = 2; | 6735 final v = c.items..[1] = 2; |
6738 '''); | 6736 '''); |
6739 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6737 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6740 isValidConst: false, | 6738 isValidConst: false, |
6741 operators: [ | 6739 operators: [ |
6742 UnlinkedConstOperation.pushReference, | 6740 UnlinkedExprOperation.pushReference, |
6743 // ..[1] = 2 | 6741 // ..[1] = 2 |
6744 UnlinkedConstOperation.cascadeSectionBegin, | 6742 UnlinkedExprOperation.cascadeSectionBegin, |
6745 UnlinkedConstOperation.pushInt, | 6743 UnlinkedExprOperation.pushInt, |
6746 UnlinkedConstOperation.pushInt, | 6744 UnlinkedExprOperation.pushInt, |
6747 UnlinkedConstOperation.assignToIndex, | 6745 UnlinkedExprOperation.assignToIndex, |
6748 // c | 6746 // c |
6749 UnlinkedConstOperation.cascadeSectionEnd, | 6747 UnlinkedExprOperation.cascadeSectionEnd, |
6750 ], | 6748 ], |
6751 assignmentOperators: [ | 6749 assignmentOperators: [ |
6752 UnlinkedExprAssignOperator.assign, | 6750 UnlinkedExprAssignOperator.assign, |
6753 ], | 6751 ], |
6754 ints: [ | 6752 ints: [ |
6755 2, | 6753 2, |
6756 1 | 6754 1 |
6757 ], | 6755 ], |
6758 strings: [], | 6756 strings: [], |
6759 referenceValidators: [ | 6757 referenceValidators: [ |
(...skipping 14 matching lines...) Expand all Loading... |
6774 class C { | 6772 class C { |
6775 int f1 = 0; | 6773 int f1 = 0; |
6776 int f2 = 0; | 6774 int f2 = 0; |
6777 } | 6775 } |
6778 final v = new C()..f1 = 1..f2 += 2; | 6776 final v = new C()..f1 = 1..f2 += 2; |
6779 '''); | 6777 '''); |
6780 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6778 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6781 isValidConst: false, | 6779 isValidConst: false, |
6782 operators: [ | 6780 operators: [ |
6783 // new C() | 6781 // new C() |
6784 UnlinkedConstOperation.invokeConstructor, | 6782 UnlinkedExprOperation.invokeConstructor, |
6785 // ..f1 = 1 | 6783 // ..f1 = 1 |
6786 UnlinkedConstOperation.cascadeSectionBegin, | 6784 UnlinkedExprOperation.cascadeSectionBegin, |
6787 UnlinkedConstOperation.pushInt, | 6785 UnlinkedExprOperation.pushInt, |
6788 UnlinkedConstOperation.assignToProperty, | 6786 UnlinkedExprOperation.assignToProperty, |
6789 // C | 6787 // C |
6790 UnlinkedConstOperation.cascadeSectionEnd, | 6788 UnlinkedExprOperation.cascadeSectionEnd, |
6791 // ..f2 += 2 | 6789 // ..f2 += 2 |
6792 UnlinkedConstOperation.cascadeSectionBegin, | 6790 UnlinkedExprOperation.cascadeSectionBegin, |
6793 UnlinkedConstOperation.pushInt, | 6791 UnlinkedExprOperation.pushInt, |
6794 UnlinkedConstOperation.assignToProperty, | 6792 UnlinkedExprOperation.assignToProperty, |
6795 // C | 6793 // C |
6796 UnlinkedConstOperation.cascadeSectionEnd, | 6794 UnlinkedExprOperation.cascadeSectionEnd, |
6797 ], | 6795 ], |
6798 assignmentOperators: [ | 6796 assignmentOperators: [ |
6799 UnlinkedExprAssignOperator.assign, | 6797 UnlinkedExprAssignOperator.assign, |
6800 UnlinkedExprAssignOperator.plus, | 6798 UnlinkedExprAssignOperator.plus, |
6801 ], | 6799 ], |
6802 ints: [ | 6800 ints: [ |
6803 0, 0, // new C() | 6801 0, 0, // new C() |
6804 1, // f1 = 1 | 6802 1, // f1 = 1 |
6805 2, // f2 += 2 | 6803 2, // f2 += 2 |
6806 ], | 6804 ], |
(...skipping 22 matching lines...) Expand all Loading... |
6829 } | 6827 } |
6830 final v = new A() | 6828 final v = new A() |
6831 ..fa1 = 1 | 6829 ..fa1 = 1 |
6832 ..b = (new B()..fb = 2) | 6830 ..b = (new B()..fb = 2) |
6833 ..fa2 = 3; | 6831 ..fa2 = 3; |
6834 '''); | 6832 '''); |
6835 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6833 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6836 isValidConst: false, | 6834 isValidConst: false, |
6837 operators: [ | 6835 operators: [ |
6838 // new A() | 6836 // new A() |
6839 UnlinkedConstOperation.invokeConstructor, | 6837 UnlinkedExprOperation.invokeConstructor, |
6840 // ..fa1 = 1 | 6838 // ..fa1 = 1 |
6841 UnlinkedConstOperation.cascadeSectionBegin, | 6839 UnlinkedExprOperation.cascadeSectionBegin, |
6842 UnlinkedConstOperation.pushInt, | 6840 UnlinkedExprOperation.pushInt, |
6843 UnlinkedConstOperation.assignToProperty, | 6841 UnlinkedExprOperation.assignToProperty, |
6844 UnlinkedConstOperation.cascadeSectionEnd, | 6842 UnlinkedExprOperation.cascadeSectionEnd, |
6845 // ..b | 6843 // ..b |
6846 UnlinkedConstOperation.cascadeSectionBegin, | 6844 UnlinkedExprOperation.cascadeSectionBegin, |
6847 // new B() | 6845 // new B() |
6848 UnlinkedConstOperation.invokeConstructor, | 6846 UnlinkedExprOperation.invokeConstructor, |
6849 // ..fb = 2 | 6847 // ..fb = 2 |
6850 UnlinkedConstOperation.cascadeSectionBegin, | 6848 UnlinkedExprOperation.cascadeSectionBegin, |
6851 UnlinkedConstOperation.pushInt, | 6849 UnlinkedExprOperation.pushInt, |
6852 UnlinkedConstOperation.assignToProperty, | 6850 UnlinkedExprOperation.assignToProperty, |
6853 UnlinkedConstOperation.cascadeSectionEnd, | 6851 UnlinkedExprOperation.cascadeSectionEnd, |
6854 // ..b = <pop value> | 6852 // ..b = <pop value> |
6855 UnlinkedConstOperation.assignToProperty, | 6853 UnlinkedExprOperation.assignToProperty, |
6856 UnlinkedConstOperation.cascadeSectionEnd, | 6854 UnlinkedExprOperation.cascadeSectionEnd, |
6857 // ..fa2 = 3 | 6855 // ..fa2 = 3 |
6858 UnlinkedConstOperation.cascadeSectionBegin, | 6856 UnlinkedExprOperation.cascadeSectionBegin, |
6859 UnlinkedConstOperation.pushInt, | 6857 UnlinkedExprOperation.pushInt, |
6860 UnlinkedConstOperation.assignToProperty, | 6858 UnlinkedExprOperation.assignToProperty, |
6861 UnlinkedConstOperation.cascadeSectionEnd, | 6859 UnlinkedExprOperation.cascadeSectionEnd, |
6862 ], | 6860 ], |
6863 assignmentOperators: [ | 6861 assignmentOperators: [ |
6864 UnlinkedExprAssignOperator.assign, | 6862 UnlinkedExprAssignOperator.assign, |
6865 UnlinkedExprAssignOperator.assign, | 6863 UnlinkedExprAssignOperator.assign, |
6866 UnlinkedExprAssignOperator.assign, | 6864 UnlinkedExprAssignOperator.assign, |
6867 UnlinkedExprAssignOperator.assign, | 6865 UnlinkedExprAssignOperator.assign, |
6868 ], | 6866 ], |
6869 ints: [ | 6867 ints: [ |
6870 0, | 6868 0, |
6871 0, | 6869 0, |
(...skipping 25 matching lines...) Expand all Loading... |
6897 class A { | 6895 class A { |
6898 int m(int _) => 0; | 6896 int m(int _) => 0; |
6899 } | 6897 } |
6900 final A a = new A(); | 6898 final A a = new A(); |
6901 final v = a..m(5).abs()..m(6); | 6899 final v = a..m(5).abs()..m(6); |
6902 '''); | 6900 '''); |
6903 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6901 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6904 isValidConst: false, | 6902 isValidConst: false, |
6905 operators: [ | 6903 operators: [ |
6906 // a | 6904 // a |
6907 UnlinkedConstOperation.pushReference, | 6905 UnlinkedExprOperation.pushReference, |
6908 // ..m(5) | 6906 // ..m(5) |
6909 UnlinkedConstOperation.cascadeSectionBegin, | 6907 UnlinkedExprOperation.cascadeSectionBegin, |
6910 UnlinkedConstOperation.pushInt, | 6908 UnlinkedExprOperation.pushInt, |
6911 UnlinkedConstOperation.invokeMethod, | 6909 UnlinkedExprOperation.invokeMethod, |
6912 // ..abs() | 6910 // ..abs() |
6913 UnlinkedConstOperation.invokeMethod, | 6911 UnlinkedExprOperation.invokeMethod, |
6914 // a | 6912 // a |
6915 UnlinkedConstOperation.cascadeSectionEnd, | 6913 UnlinkedExprOperation.cascadeSectionEnd, |
6916 // ..m(6) | 6914 // ..m(6) |
6917 UnlinkedConstOperation.cascadeSectionBegin, | 6915 UnlinkedExprOperation.cascadeSectionBegin, |
6918 UnlinkedConstOperation.pushInt, | 6916 UnlinkedExprOperation.pushInt, |
6919 UnlinkedConstOperation.invokeMethod, | 6917 UnlinkedExprOperation.invokeMethod, |
6920 // a | 6918 // a |
6921 UnlinkedConstOperation.cascadeSectionEnd, | 6919 UnlinkedExprOperation.cascadeSectionEnd, |
6922 ], | 6920 ], |
6923 ints: [ | 6921 ints: [ |
6924 5, 0, 1, 0, // m(5) | 6922 5, 0, 1, 0, // m(5) |
6925 0, 0, 0, // abs() | 6923 0, 0, 0, // abs() |
6926 6, 0, 1, 0, // m(5) | 6924 6, 0, 1, 0, // m(5) |
6927 ], | 6925 ], |
6928 strings: [ | 6926 strings: [ |
6929 'm', | 6927 'm', |
6930 'abs', | 6928 'abs', |
6931 'm', | 6929 'm', |
(...skipping 10 matching lines...) Expand all Loading... |
6942 } | 6940 } |
6943 UnlinkedVariable variable = serializeVariableText(''' | 6941 UnlinkedVariable variable = serializeVariableText(''' |
6944 class C { | 6942 class C { |
6945 List<int> get items => null; | 6943 List<int> get items => null; |
6946 } | 6944 } |
6947 final v = new C().items[5]; | 6945 final v = new C().items[5]; |
6948 '''); | 6946 '''); |
6949 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6947 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6950 isValidConst: false, | 6948 isValidConst: false, |
6951 operators: [ | 6949 operators: [ |
6952 UnlinkedConstOperation.invokeConstructor, | 6950 UnlinkedExprOperation.invokeConstructor, |
6953 UnlinkedConstOperation.extractProperty, | 6951 UnlinkedExprOperation.extractProperty, |
6954 UnlinkedConstOperation.pushInt, | 6952 UnlinkedExprOperation.pushInt, |
6955 UnlinkedConstOperation.extractIndex, | 6953 UnlinkedExprOperation.extractIndex, |
6956 ], | 6954 ], |
6957 ints: [ | 6955 ints: [ |
6958 0, | 6956 0, |
6959 0, | 6957 0, |
6960 5 | 6958 5 |
6961 ], | 6959 ], |
6962 strings: [ | 6960 strings: [ |
6963 'items' | 6961 'items' |
6964 ], | 6962 ], |
6965 referenceValidators: [ | 6963 referenceValidators: [ |
6966 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6964 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
6967 expectedKind: ReferenceKind.classOrEnum) | 6965 expectedKind: ReferenceKind.classOrEnum) |
6968 ]); | 6966 ]); |
6969 } | 6967 } |
6970 | 6968 |
6971 test_expr_extractProperty_ofInvokeConstructor() { | 6969 test_expr_extractProperty_ofInvokeConstructor() { |
6972 if (skipNonConstInitializers) { | 6970 if (skipNonConstInitializers) { |
6973 return; | 6971 return; |
6974 } | 6972 } |
6975 UnlinkedVariable variable = serializeVariableText(''' | 6973 UnlinkedVariable variable = serializeVariableText(''' |
6976 class C { | 6974 class C { |
6977 int f = 0; | 6975 int f = 0; |
6978 } | 6976 } |
6979 final v = new C().f; | 6977 final v = new C().f; |
6980 '''); | 6978 '''); |
6981 _assertUnlinkedConst(variable.initializer.bodyExpr, | 6979 _assertUnlinkedConst(variable.initializer.bodyExpr, |
6982 isValidConst: false, | 6980 isValidConst: false, |
6983 operators: [ | 6981 operators: [ |
6984 UnlinkedConstOperation.invokeConstructor, | 6982 UnlinkedExprOperation.invokeConstructor, |
6985 UnlinkedConstOperation.extractProperty, | 6983 UnlinkedExprOperation.extractProperty, |
6986 ], | 6984 ], |
6987 ints: [ | 6985 ints: [ |
6988 0, | 6986 0, |
6989 0 | 6987 0 |
6990 ], | 6988 ], |
6991 strings: [ | 6989 strings: [ |
6992 'f' | 6990 'f' |
6993 ], | 6991 ], |
6994 referenceValidators: [ | 6992 referenceValidators: [ |
6995 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6993 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
6996 expectedKind: ReferenceKind.classOrEnum) | 6994 expectedKind: ReferenceKind.classOrEnum) |
6997 ]); | 6995 ]); |
6998 } | 6996 } |
6999 | 6997 |
7000 test_expr_functionExpression_asArgument() { | 6998 test_expr_functionExpression_asArgument() { |
7001 if (skipNonConstInitializers) { | 6999 if (skipNonConstInitializers) { |
7002 return; | 7000 return; |
7003 } | 7001 } |
7004 UnlinkedVariable variable = serializeVariableText(''' | 7002 UnlinkedVariable variable = serializeVariableText(''' |
7005 final v = foo(5, () => 42); | 7003 final v = foo(5, () => 42); |
7006 foo(a, b) {} | 7004 foo(a, b) {} |
7007 '''); | 7005 '''); |
7008 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7006 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7009 isValidConst: false, | 7007 isValidConst: false, |
7010 operators: [ | 7008 operators: [ |
7011 UnlinkedConstOperation.pushInt, | 7009 UnlinkedExprOperation.pushInt, |
7012 UnlinkedConstOperation.pushLocalFunctionReference, | 7010 UnlinkedExprOperation.pushLocalFunctionReference, |
7013 UnlinkedConstOperation.invokeMethodRef | 7011 UnlinkedExprOperation.invokeMethodRef |
7014 ], | 7012 ], |
7015 ints: [ | 7013 ints: [ |
7016 5, | 7014 5, |
7017 0, | 7015 0, |
7018 0, | 7016 0, |
7019 0, | 7017 0, |
7020 2, | 7018 2, |
7021 0 | 7019 0 |
7022 ], | 7020 ], |
7023 referenceValidators: [ | 7021 referenceValidators: [ |
7024 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 7022 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
7025 expectedKind: ReferenceKind.topLevelFunction) | 7023 expectedKind: ReferenceKind.topLevelFunction) |
7026 ]); | 7024 ]); |
7027 } | 7025 } |
7028 | 7026 |
7029 test_expr_functionExpression_asArgument_multiple() { | 7027 test_expr_functionExpression_asArgument_multiple() { |
7030 if (skipNonConstInitializers) { | 7028 if (skipNonConstInitializers) { |
7031 return; | 7029 return; |
7032 } | 7030 } |
7033 UnlinkedVariable variable = serializeVariableText(''' | 7031 UnlinkedVariable variable = serializeVariableText(''' |
7034 final v = foo(5, () => 42, () => 43); | 7032 final v = foo(5, () => 42, () => 43); |
7035 foo(a, b, c) {} | 7033 foo(a, b, c) {} |
7036 '''); | 7034 '''); |
7037 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7035 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7038 isValidConst: false, | 7036 isValidConst: false, |
7039 operators: [ | 7037 operators: [ |
7040 UnlinkedConstOperation.pushInt, | 7038 UnlinkedExprOperation.pushInt, |
7041 UnlinkedConstOperation.pushLocalFunctionReference, | 7039 UnlinkedExprOperation.pushLocalFunctionReference, |
7042 UnlinkedConstOperation.pushLocalFunctionReference, | 7040 UnlinkedExprOperation.pushLocalFunctionReference, |
7043 UnlinkedConstOperation.invokeMethodRef | 7041 UnlinkedExprOperation.invokeMethodRef |
7044 ], | 7042 ], |
7045 ints: [ | 7043 ints: [ |
7046 5, | 7044 5, |
7047 0, | 7045 0, |
7048 0, | 7046 0, |
7049 0, | 7047 0, |
7050 1, | 7048 1, |
7051 0, | 7049 0, |
7052 3, | 7050 3, |
7053 0 | 7051 0 |
7054 ], | 7052 ], |
7055 referenceValidators: [ | 7053 referenceValidators: [ |
7056 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 7054 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
7057 expectedKind: ReferenceKind.topLevelFunction) | 7055 expectedKind: ReferenceKind.topLevelFunction) |
7058 ]); | 7056 ]); |
7059 } | 7057 } |
7060 | 7058 |
7061 test_expr_functionExpression_withBlockBody() { | 7059 test_expr_functionExpression_withBlockBody() { |
7062 if (skipNonConstInitializers) { | 7060 if (skipNonConstInitializers) { |
7063 return; | 7061 return; |
7064 } | 7062 } |
7065 UnlinkedVariable variable = serializeVariableText(''' | 7063 UnlinkedVariable variable = serializeVariableText(''' |
7066 final v = () { return 42; }; | 7064 final v = () { return 42; }; |
7067 '''); | 7065 '''); |
7068 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7066 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7069 isValidConst: false, | 7067 isValidConst: false, |
7070 operators: [UnlinkedConstOperation.pushLocalFunctionReference], | 7068 operators: [UnlinkedExprOperation.pushLocalFunctionReference], |
7071 ints: [0, 0]); | 7069 ints: [0, 0]); |
7072 } | 7070 } |
7073 | 7071 |
7074 test_expr_functionExpression_withExpressionBody() { | 7072 test_expr_functionExpression_withExpressionBody() { |
7075 if (skipNonConstInitializers) { | 7073 if (skipNonConstInitializers) { |
7076 return; | 7074 return; |
7077 } | 7075 } |
7078 UnlinkedVariable variable = serializeVariableText(''' | 7076 UnlinkedVariable variable = serializeVariableText(''' |
7079 final v = () => 42; | 7077 final v = () => 42; |
7080 '''); | 7078 '''); |
7081 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7079 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7082 isValidConst: false, | 7080 isValidConst: false, |
7083 operators: [UnlinkedConstOperation.pushLocalFunctionReference], | 7081 operators: [UnlinkedExprOperation.pushLocalFunctionReference], |
7084 ints: [0, 0]); | 7082 ints: [0, 0]); |
7085 } | 7083 } |
7086 | 7084 |
7087 test_expr_functionExpressionInvocation_withBlockBody() { | 7085 test_expr_functionExpressionInvocation_withBlockBody() { |
7088 if (skipNonConstInitializers) { | 7086 if (skipNonConstInitializers) { |
7089 return; | 7087 return; |
7090 } | 7088 } |
7091 UnlinkedVariable variable = serializeVariableText(''' | 7089 UnlinkedVariable variable = serializeVariableText(''' |
7092 final v = ((a, b) {return 42;})(1, 2); | 7090 final v = ((a, b) {return 42;})(1, 2); |
7093 '''); | 7091 '''); |
7094 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7092 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7095 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); | 7093 isValidConst: false, operators: [UnlinkedExprOperation.pushNull]); |
7096 } | 7094 } |
7097 | 7095 |
7098 test_expr_functionExpressionInvocation_withExpressionBody() { | 7096 test_expr_functionExpressionInvocation_withExpressionBody() { |
7099 if (skipNonConstInitializers) { | 7097 if (skipNonConstInitializers) { |
7100 return; | 7098 return; |
7101 } | 7099 } |
7102 UnlinkedVariable variable = serializeVariableText(''' | 7100 UnlinkedVariable variable = serializeVariableText(''' |
7103 final v = ((a, b) => 42)(1, 2); | 7101 final v = ((a, b) => 42)(1, 2); |
7104 '''); | 7102 '''); |
7105 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7103 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7106 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); | 7104 isValidConst: false, operators: [UnlinkedExprOperation.pushNull]); |
7107 } | 7105 } |
7108 | 7106 |
7109 test_expr_inClosure() { | 7107 test_expr_inClosure() { |
7110 if (skipNonConstInitializers) { | 7108 if (skipNonConstInitializers) { |
7111 return; | 7109 return; |
7112 } | 7110 } |
7113 UnlinkedVariable variable = serializeVariableText('var v = () => 1;'); | 7111 UnlinkedVariable variable = serializeVariableText('var v = () => 1;'); |
7114 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7112 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7115 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 7113 operators: [UnlinkedExprOperation.pushInt], ints: [1]); |
7116 } | 7114 } |
7117 | 7115 |
7118 test_expr_inClosure_noTypeInferenceNeeded() { | 7116 test_expr_inClosure_noTypeInferenceNeeded() { |
7119 // We don't serialize closure body expressions for closures that don't need | 7117 // We don't serialize closure body expressions for closures that don't need |
7120 // to participate in type inference. | 7118 // to participate in type inference. |
7121 UnlinkedVariable variable = serializeVariableText('Object v = () => 1;'); | 7119 UnlinkedVariable variable = serializeVariableText('Object v = () => 1;'); |
7122 expect(variable.initializer.localFunctions[0].bodyExpr, isNull); | 7120 expect(variable.initializer.localFunctions[0].bodyExpr, isNull); |
7123 } | 7121 } |
7124 | 7122 |
7125 test_expr_inClosure_refersToOuterParam() { | 7123 test_expr_inClosure_refersToOuterParam() { |
7126 if (skipNonConstInitializers) { | 7124 if (skipNonConstInitializers) { |
7127 return; | 7125 return; |
7128 } | 7126 } |
7129 UnlinkedVariable variable = | 7127 UnlinkedVariable variable = |
7130 serializeVariableText('var v = (x) => (y) => x;'); | 7128 serializeVariableText('var v = (x) => (y) => x;'); |
7131 _assertUnlinkedConst( | 7129 _assertUnlinkedConst( |
7132 variable.initializer.localFunctions[0].localFunctions[0].bodyExpr, | 7130 variable.initializer.localFunctions[0].localFunctions[0].bodyExpr, |
7133 operators: [UnlinkedConstOperation.pushParameter], | 7131 operators: [UnlinkedExprOperation.pushParameter], |
7134 strings: ['x']); | 7132 strings: ['x']); |
7135 } | 7133 } |
7136 | 7134 |
7137 test_expr_inClosure_refersToParam() { | 7135 test_expr_inClosure_refersToParam() { |
7138 if (skipNonConstInitializers) { | 7136 if (skipNonConstInitializers) { |
7139 return; | 7137 return; |
7140 } | 7138 } |
7141 UnlinkedVariable variable = serializeVariableText('var v = (x) => x;'); | 7139 UnlinkedVariable variable = serializeVariableText('var v = (x) => x;'); |
7142 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7140 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7143 operators: [UnlinkedConstOperation.pushParameter], strings: ['x']); | 7141 operators: [UnlinkedExprOperation.pushParameter], strings: ['x']); |
7144 } | 7142 } |
7145 | 7143 |
7146 test_expr_inClosure_refersToParam_methodCall() { | 7144 test_expr_inClosure_refersToParam_methodCall() { |
7147 if (skipNonConstInitializers) { | 7145 if (skipNonConstInitializers) { |
7148 return; | 7146 return; |
7149 } | 7147 } |
7150 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.f();'); | 7148 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.f();'); |
7151 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7149 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7152 isValidConst: false, | 7150 isValidConst: false, |
7153 operators: [ | 7151 operators: [ |
7154 UnlinkedConstOperation.pushParameter, | 7152 UnlinkedExprOperation.pushParameter, |
7155 UnlinkedConstOperation.invokeMethod | 7153 UnlinkedExprOperation.invokeMethod |
7156 ], | 7154 ], |
7157 strings: [ | 7155 strings: [ |
7158 'x', | 7156 'x', |
7159 'f' | 7157 'f' |
7160 ], | 7158 ], |
7161 ints: [ | 7159 ints: [ |
7162 0, | 7160 0, |
7163 0, | 7161 0, |
7164 0 | 7162 0 |
7165 ]); | 7163 ]); |
7166 } | 7164 } |
7167 | 7165 |
7168 test_expr_inClosure_refersToParam_methodCall_prefixed() { | 7166 test_expr_inClosure_refersToParam_methodCall_prefixed() { |
7169 if (skipNonConstInitializers) { | 7167 if (skipNonConstInitializers) { |
7170 return; | 7168 return; |
7171 } | 7169 } |
7172 UnlinkedVariable variable = | 7170 UnlinkedVariable variable = |
7173 serializeVariableText('var v = (x) => x.y.f();'); | 7171 serializeVariableText('var v = (x) => x.y.f();'); |
7174 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7172 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7175 isValidConst: false, | 7173 isValidConst: false, |
7176 operators: [ | 7174 operators: [ |
7177 UnlinkedConstOperation.pushParameter, | 7175 UnlinkedExprOperation.pushParameter, |
7178 UnlinkedConstOperation.extractProperty, | 7176 UnlinkedExprOperation.extractProperty, |
7179 UnlinkedConstOperation.invokeMethod | 7177 UnlinkedExprOperation.invokeMethod |
7180 ], | 7178 ], |
7181 strings: [ | 7179 strings: [ |
7182 'x', | 7180 'x', |
7183 'y', | 7181 'y', |
7184 'f' | 7182 'f' |
7185 ], | 7183 ], |
7186 ints: [ | 7184 ints: [ |
7187 0, | 7185 0, |
7188 0, | 7186 0, |
7189 0 | 7187 0 |
7190 ]); | 7188 ]); |
7191 } | 7189 } |
7192 | 7190 |
7193 test_expr_inClosure_refersToParam_outOfScope() { | 7191 test_expr_inClosure_refersToParam_outOfScope() { |
7194 if (skipNonConstInitializers) { | 7192 if (skipNonConstInitializers) { |
7195 return; | 7193 return; |
7196 } | 7194 } |
7197 UnlinkedVariable variable = | 7195 UnlinkedVariable variable = |
7198 serializeVariableText('var x; var v = (b) => (b ? (x) => x : x);'); | 7196 serializeVariableText('var x; var v = (b) => (b ? (x) => x : x);'); |
7199 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7197 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7200 isValidConst: false, | 7198 isValidConst: false, |
7201 operators: [ | 7199 operators: [ |
7202 UnlinkedConstOperation.pushParameter, | 7200 UnlinkedExprOperation.pushParameter, |
7203 UnlinkedConstOperation.pushLocalFunctionReference, | 7201 UnlinkedExprOperation.pushLocalFunctionReference, |
7204 UnlinkedConstOperation.pushReference, | 7202 UnlinkedExprOperation.pushReference, |
7205 UnlinkedConstOperation.conditional, | 7203 UnlinkedExprOperation.conditional, |
7206 ], | 7204 ], |
7207 strings: [ | 7205 strings: [ |
7208 'b' | 7206 'b' |
7209 ], | 7207 ], |
7210 ints: [ | 7208 ints: [ |
7211 0, | 7209 0, |
7212 0 | 7210 0 |
7213 ], | 7211 ], |
7214 referenceValidators: [ | 7212 referenceValidators: [ |
7215 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 7213 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
7216 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 7214 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
7217 ]); | 7215 ]); |
7218 } | 7216 } |
7219 | 7217 |
7220 test_expr_inClosure_refersToParam_prefixedIdentifier() { | 7218 test_expr_inClosure_refersToParam_prefixedIdentifier() { |
7221 if (skipNonConstInitializers) { | 7219 if (skipNonConstInitializers) { |
7222 return; | 7220 return; |
7223 } | 7221 } |
7224 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y;'); | 7222 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y;'); |
7225 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7223 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7226 operators: [ | 7224 operators: [ |
7227 UnlinkedConstOperation.pushParameter, | 7225 UnlinkedExprOperation.pushParameter, |
7228 UnlinkedConstOperation.extractProperty | 7226 UnlinkedExprOperation.extractProperty |
7229 ], | 7227 ], |
7230 strings: [ | 7228 strings: [ |
7231 'x', | 7229 'x', |
7232 'y' | 7230 'y' |
7233 ]); | 7231 ]); |
7234 } | 7232 } |
7235 | 7233 |
7236 test_expr_inClosure_refersToParam_prefixedIdentifier_assign() { | 7234 test_expr_inClosure_refersToParam_prefixedIdentifier_assign() { |
7237 if (skipNonConstInitializers) { | 7235 if (skipNonConstInitializers) { |
7238 return; | 7236 return; |
7239 } | 7237 } |
7240 UnlinkedVariable variable = | 7238 UnlinkedVariable variable = |
7241 serializeVariableText('var v = (x) => x.y = null;'); | 7239 serializeVariableText('var v = (x) => x.y = null;'); |
7242 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7240 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7243 isValidConst: false, | 7241 isValidConst: false, |
7244 operators: [ | 7242 operators: [ |
7245 UnlinkedConstOperation.pushNull, | 7243 UnlinkedExprOperation.pushNull, |
7246 UnlinkedConstOperation.pushParameter, | 7244 UnlinkedExprOperation.pushParameter, |
7247 UnlinkedConstOperation.assignToProperty | 7245 UnlinkedExprOperation.assignToProperty |
7248 ], | 7246 ], |
7249 strings: [ | 7247 strings: [ |
7250 'x', | 7248 'x', |
7251 'y' | 7249 'y' |
7252 ], | 7250 ], |
7253 assignmentOperators: [ | 7251 assignmentOperators: [ |
7254 UnlinkedExprAssignOperator.assign | 7252 UnlinkedExprAssignOperator.assign |
7255 ]); | 7253 ]); |
7256 } | 7254 } |
7257 | 7255 |
7258 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier() { | 7256 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier() { |
7259 if (skipNonConstInitializers) { | 7257 if (skipNonConstInitializers) { |
7260 return; | 7258 return; |
7261 } | 7259 } |
7262 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y.z;'); | 7260 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y.z;'); |
7263 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7261 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7264 operators: [ | 7262 operators: [ |
7265 UnlinkedConstOperation.pushParameter, | 7263 UnlinkedExprOperation.pushParameter, |
7266 UnlinkedConstOperation.extractProperty, | 7264 UnlinkedExprOperation.extractProperty, |
7267 UnlinkedConstOperation.extractProperty | 7265 UnlinkedExprOperation.extractProperty |
7268 ], | 7266 ], |
7269 strings: [ | 7267 strings: [ |
7270 'x', | 7268 'x', |
7271 'y', | 7269 'y', |
7272 'z' | 7270 'z' |
7273 ]); | 7271 ]); |
7274 } | 7272 } |
7275 | 7273 |
7276 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier_assign() { | 7274 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier_assign() { |
7277 if (skipNonConstInitializers) { | 7275 if (skipNonConstInitializers) { |
7278 return; | 7276 return; |
7279 } | 7277 } |
7280 UnlinkedVariable variable = | 7278 UnlinkedVariable variable = |
7281 serializeVariableText('var v = (x) => x.y.z = null;'); | 7279 serializeVariableText('var v = (x) => x.y.z = null;'); |
7282 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7280 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7283 isValidConst: false, | 7281 isValidConst: false, |
7284 operators: [ | 7282 operators: [ |
7285 UnlinkedConstOperation.pushNull, | 7283 UnlinkedExprOperation.pushNull, |
7286 UnlinkedConstOperation.pushParameter, | 7284 UnlinkedExprOperation.pushParameter, |
7287 UnlinkedConstOperation.extractProperty, | 7285 UnlinkedExprOperation.extractProperty, |
7288 UnlinkedConstOperation.assignToProperty | 7286 UnlinkedExprOperation.assignToProperty |
7289 ], | 7287 ], |
7290 strings: [ | 7288 strings: [ |
7291 'x', | 7289 'x', |
7292 'y', | 7290 'y', |
7293 'z' | 7291 'z' |
7294 ], | 7292 ], |
7295 assignmentOperators: [ | 7293 assignmentOperators: [ |
7296 UnlinkedExprAssignOperator.assign | 7294 UnlinkedExprAssignOperator.assign |
7297 ]); | 7295 ]); |
7298 } | 7296 } |
7299 | 7297 |
7300 test_expr_invokeMethod_instance() { | 7298 test_expr_invokeMethod_instance() { |
7301 if (skipNonConstInitializers) { | 7299 if (skipNonConstInitializers) { |
7302 return; | 7300 return; |
7303 } | 7301 } |
7304 UnlinkedVariable variable = serializeVariableText(''' | 7302 UnlinkedVariable variable = serializeVariableText(''' |
7305 class C { | 7303 class C { |
7306 int m(a, {b, c}) => 42; | 7304 int m(a, {b, c}) => 42; |
7307 } | 7305 } |
7308 final v = new C().m(1, b: 2, c: 3); | 7306 final v = new C().m(1, b: 2, c: 3); |
7309 '''); | 7307 '''); |
7310 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7308 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7311 isValidConst: false, | 7309 isValidConst: false, |
7312 operators: [ | 7310 operators: [ |
7313 UnlinkedConstOperation.invokeConstructor, | 7311 UnlinkedExprOperation.invokeConstructor, |
7314 UnlinkedConstOperation.pushInt, | 7312 UnlinkedExprOperation.pushInt, |
7315 UnlinkedConstOperation.pushInt, | 7313 UnlinkedExprOperation.pushInt, |
7316 UnlinkedConstOperation.pushInt, | 7314 UnlinkedExprOperation.pushInt, |
7317 UnlinkedConstOperation.invokeMethod, | 7315 UnlinkedExprOperation.invokeMethod, |
7318 ], | 7316 ], |
7319 ints: [ | 7317 ints: [ |
7320 0, | 7318 0, |
7321 0, | 7319 0, |
7322 1, | 7320 1, |
7323 2, | 7321 2, |
7324 3, | 7322 3, |
7325 2, | 7323 2, |
7326 1, | 7324 1, |
7327 0 | 7325 0 |
(...skipping 15 matching lines...) Expand all Loading... |
7343 } | 7341 } |
7344 UnlinkedVariable variable = serializeVariableText(''' | 7342 UnlinkedVariable variable = serializeVariableText(''' |
7345 class C { | 7343 class C { |
7346 f<T, U>() => null; | 7344 f<T, U>() => null; |
7347 } | 7345 } |
7348 final v = new C().f<int, String>(); | 7346 final v = new C().f<int, String>(); |
7349 '''); | 7347 '''); |
7350 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7348 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7351 isValidConst: false, | 7349 isValidConst: false, |
7352 operators: [ | 7350 operators: [ |
7353 UnlinkedConstOperation.invokeConstructor, | 7351 UnlinkedExprOperation.invokeConstructor, |
7354 UnlinkedConstOperation.invokeMethod | 7352 UnlinkedExprOperation.invokeMethod |
7355 ], | 7353 ], |
7356 ints: [ | 7354 ints: [ |
7357 0, | 7355 0, |
7358 0, | 7356 0, |
7359 0, | 7357 0, |
7360 0, | 7358 0, |
7361 2 | 7359 2 |
7362 ], | 7360 ], |
7363 strings: [ | 7361 strings: [ |
7364 'f' | 7362 'f' |
(...skipping 18 matching lines...) Expand all Loading... |
7383 } | 7381 } |
7384 class C { | 7382 class C { |
7385 int m(int a, int b) => a + b; | 7383 int m(int a, int b) => a + b; |
7386 } | 7384 } |
7387 A a = new A(); | 7385 A a = new A(); |
7388 final v = a.b.c.m(10, 20); | 7386 final v = a.b.c.m(10, 20); |
7389 '''); | 7387 '''); |
7390 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7388 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7391 isValidConst: false, | 7389 isValidConst: false, |
7392 operators: [ | 7390 operators: [ |
7393 UnlinkedConstOperation.pushInt, | 7391 UnlinkedExprOperation.pushInt, |
7394 UnlinkedConstOperation.pushInt, | 7392 UnlinkedExprOperation.pushInt, |
7395 UnlinkedConstOperation.invokeMethodRef, | 7393 UnlinkedExprOperation.invokeMethodRef, |
7396 ], | 7394 ], |
7397 ints: [ | 7395 ints: [ |
7398 10, | 7396 10, |
7399 20, | 7397 20, |
7400 0, | 7398 0, |
7401 2, | 7399 2, |
7402 0 | 7400 0 |
7403 ], | 7401 ], |
7404 strings: [], | 7402 strings: [], |
7405 referenceValidators: [ | 7403 referenceValidators: [ |
(...skipping 19 matching lines...) Expand all Loading... |
7425 static int m() => 42; | 7423 static int m() => 42; |
7426 } | 7424 } |
7427 '''); | 7425 '''); |
7428 UnlinkedVariable variable = serializeVariableText(''' | 7426 UnlinkedVariable variable = serializeVariableText(''' |
7429 import 'a.dart' as p; | 7427 import 'a.dart' as p; |
7430 final v = p.C.m(); | 7428 final v = p.C.m(); |
7431 '''); | 7429 '''); |
7432 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7430 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7433 isValidConst: false, | 7431 isValidConst: false, |
7434 operators: [ | 7432 operators: [ |
7435 UnlinkedConstOperation.invokeMethodRef, | 7433 UnlinkedExprOperation.invokeMethodRef, |
7436 ], | 7434 ], |
7437 ints: [ | 7435 ints: [ |
7438 0, | 7436 0, |
7439 0, | 7437 0, |
7440 0 | 7438 0 |
7441 ], | 7439 ], |
7442 strings: [], | 7440 strings: [], |
7443 referenceValidators: [ | 7441 referenceValidators: [ |
7444 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 7442 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
7445 expectedKind: ReferenceKind.method, | 7443 expectedKind: ReferenceKind.method, |
(...skipping 10 matching lines...) Expand all Loading... |
7456 return; | 7454 return; |
7457 } | 7455 } |
7458 UnlinkedVariable variable = serializeVariableText(''' | 7456 UnlinkedVariable variable = serializeVariableText(''' |
7459 f(x) => null; | 7457 f(x) => null; |
7460 final u = null; | 7458 final u = null; |
7461 final v = f(u); | 7459 final v = f(u); |
7462 '''); | 7460 '''); |
7463 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7461 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7464 isValidConst: false, | 7462 isValidConst: false, |
7465 operators: [ | 7463 operators: [ |
7466 UnlinkedConstOperation.pushReference, | 7464 UnlinkedExprOperation.pushReference, |
7467 UnlinkedConstOperation.invokeMethodRef | 7465 UnlinkedExprOperation.invokeMethodRef |
7468 ], | 7466 ], |
7469 ints: [ | 7467 ints: [ |
7470 0, | 7468 0, |
7471 1, | 7469 1, |
7472 0 | 7470 0 |
7473 ], | 7471 ], |
7474 referenceValidators: [ | 7472 referenceValidators: [ |
7475 (EntityRef r) => checkTypeRef(r, null, null, 'u', | 7473 (EntityRef r) => checkTypeRef(r, null, null, 'u', |
7476 expectedKind: ReferenceKind.topLevelPropertyAccessor), | 7474 expectedKind: ReferenceKind.topLevelPropertyAccessor), |
7477 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 7475 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
7478 expectedKind: ReferenceKind.topLevelFunction) | 7476 expectedKind: ReferenceKind.topLevelFunction) |
7479 ]); | 7477 ]); |
7480 } | 7478 } |
7481 | 7479 |
7482 test_expr_invokeMethodRef_withTypeParameters() { | 7480 test_expr_invokeMethodRef_withTypeParameters() { |
7483 if (skipNonConstInitializers) { | 7481 if (skipNonConstInitializers) { |
7484 return; | 7482 return; |
7485 } | 7483 } |
7486 UnlinkedVariable variable = serializeVariableText(''' | 7484 UnlinkedVariable variable = serializeVariableText(''' |
7487 f<T, U>() => null; | 7485 f<T, U>() => null; |
7488 final v = f<int, String>(); | 7486 final v = f<int, String>(); |
7489 '''); | 7487 '''); |
7490 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7488 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7491 isValidConst: false, | 7489 isValidConst: false, |
7492 operators: [ | 7490 operators: [ |
7493 UnlinkedConstOperation.invokeMethodRef | 7491 UnlinkedExprOperation.invokeMethodRef |
7494 ], | 7492 ], |
7495 ints: [ | 7493 ints: [ |
7496 0, | 7494 0, |
7497 0, | 7495 0, |
7498 2 | 7496 2 |
7499 ], | 7497 ], |
7500 referenceValidators: [ | 7498 referenceValidators: [ |
7501 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 7499 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
7502 expectedKind: ReferenceKind.topLevelFunction, | 7500 expectedKind: ReferenceKind.topLevelFunction, |
7503 numTypeParameters: 2), | 7501 numTypeParameters: 2), |
7504 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'), | 7502 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'), |
7505 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String') | 7503 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String') |
7506 ]); | 7504 ]); |
7507 } | 7505 } |
7508 | 7506 |
7509 test_expr_throwException() { | 7507 test_expr_throwException() { |
7510 if (skipNonConstInitializers) { | 7508 if (skipNonConstInitializers) { |
7511 return; | 7509 return; |
7512 } | 7510 } |
7513 UnlinkedVariable variable = serializeVariableText(''' | 7511 UnlinkedVariable variable = serializeVariableText(''' |
7514 final v = throw 1 + 2; | 7512 final v = throw 1 + 2; |
7515 '''); | 7513 '''); |
7516 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7514 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7517 isValidConst: false, | 7515 isValidConst: false, |
7518 operators: [ | 7516 operators: [ |
7519 UnlinkedConstOperation.pushInt, | 7517 UnlinkedExprOperation.pushInt, |
7520 UnlinkedConstOperation.pushInt, | 7518 UnlinkedExprOperation.pushInt, |
7521 UnlinkedConstOperation.add, | 7519 UnlinkedExprOperation.add, |
7522 UnlinkedConstOperation.throwException, | 7520 UnlinkedExprOperation.throwException, |
7523 ], | 7521 ], |
7524 ints: [ | 7522 ints: [ |
7525 1, | 7523 1, |
7526 2 | 7524 2 |
7527 ]); | 7525 ]); |
7528 } | 7526 } |
7529 | 7527 |
7530 test_expr_typeCast() { | 7528 test_expr_typeCast() { |
7531 if (skipNonConstInitializers) { | 7529 if (skipNonConstInitializers) { |
7532 return; | 7530 return; |
7533 } | 7531 } |
7534 UnlinkedVariable variable = serializeVariableText(''' | 7532 UnlinkedVariable variable = serializeVariableText(''' |
7535 final v = 42 as num; | 7533 final v = 42 as num; |
7536 '''); | 7534 '''); |
7537 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7535 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7538 isValidConst: false, | 7536 isValidConst: false, |
7539 operators: [ | 7537 operators: [ |
7540 UnlinkedConstOperation.pushInt, | 7538 UnlinkedExprOperation.pushInt, |
7541 UnlinkedConstOperation.typeCast, | 7539 UnlinkedExprOperation.typeCast, |
7542 ], | 7540 ], |
7543 ints: [ | 7541 ints: [ |
7544 42 | 7542 42 |
7545 ], | 7543 ], |
7546 referenceValidators: [ | 7544 referenceValidators: [ |
7547 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 7545 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', |
7548 expectedKind: ReferenceKind.classOrEnum) | 7546 expectedKind: ReferenceKind.classOrEnum) |
7549 ]); | 7547 ]); |
7550 } | 7548 } |
7551 | 7549 |
7552 test_expr_typeCheck() { | 7550 test_expr_typeCheck() { |
7553 if (skipNonConstInitializers) { | 7551 if (skipNonConstInitializers) { |
7554 return; | 7552 return; |
7555 } | 7553 } |
7556 UnlinkedVariable variable = serializeVariableText(''' | 7554 UnlinkedVariable variable = serializeVariableText(''' |
7557 final v = 42 is num; | 7555 final v = 42 is num; |
7558 '''); | 7556 '''); |
7559 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7557 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7560 isValidConst: false, | 7558 isValidConst: false, |
7561 operators: [ | 7559 operators: [ |
7562 UnlinkedConstOperation.pushInt, | 7560 UnlinkedExprOperation.pushInt, |
7563 UnlinkedConstOperation.typeCheck, | 7561 UnlinkedExprOperation.typeCheck, |
7564 ], | 7562 ], |
7565 ints: [ | 7563 ints: [ |
7566 42 | 7564 42 |
7567 ], | 7565 ], |
7568 referenceValidators: [ | 7566 referenceValidators: [ |
7569 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 7567 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', |
7570 expectedKind: ReferenceKind.classOrEnum) | 7568 expectedKind: ReferenceKind.classOrEnum) |
7571 ]); | 7569 ]); |
7572 } | 7570 } |
7573 | 7571 |
(...skipping 10 matching lines...) Expand all Loading... |
7584 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 7582 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
7585 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); | 7583 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
7586 expect(unlinkedUnits[0].publicNamespace.names[0].members, isEmpty); | 7584 expect(unlinkedUnits[0].publicNamespace.names[0].members, isEmpty); |
7587 } | 7585 } |
7588 | 7586 |
7589 test_field_const() { | 7587 test_field_const() { |
7590 UnlinkedVariable variable = | 7588 UnlinkedVariable variable = |
7591 serializeClassText('class C { static const int i = 0; }').fields[0]; | 7589 serializeClassText('class C { static const int i = 0; }').fields[0]; |
7592 expect(variable.isConst, isTrue); | 7590 expect(variable.isConst, isTrue); |
7593 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7591 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7594 operators: [UnlinkedConstOperation.pushInt], ints: [0]); | 7592 operators: [UnlinkedExprOperation.pushInt], ints: [0]); |
7595 } | 7593 } |
7596 | 7594 |
7597 test_field_documented() { | 7595 test_field_documented() { |
7598 String text = ''' | 7596 String text = ''' |
7599 class C { | 7597 class C { |
7600 /** | 7598 /** |
7601 * Docs | 7599 * Docs |
7602 */ | 7600 */ |
7603 var v; | 7601 var v; |
7604 }'''; | 7602 }'''; |
7605 UnlinkedVariable variable = serializeClassText(text).fields[0]; | 7603 UnlinkedVariable variable = serializeClassText(text).fields[0]; |
7606 expect(variable.documentationComment, isNotNull); | 7604 expect(variable.documentationComment, isNotNull); |
7607 checkDocumentationComment(variable.documentationComment, text); | 7605 checkDocumentationComment(variable.documentationComment, text); |
7608 } | 7606 } |
7609 | 7607 |
7610 test_field_final() { | 7608 test_field_final() { |
7611 UnlinkedVariable variable = | 7609 UnlinkedVariable variable = |
7612 serializeClassText('class C { final int i = 0; }').fields[0]; | 7610 serializeClassText('class C { final int i = 0; }').fields[0]; |
7613 expect(variable.isFinal, isTrue); | 7611 expect(variable.isFinal, isTrue); |
7614 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7612 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7615 operators: [UnlinkedConstOperation.pushInt], ints: [0]); | 7613 operators: [UnlinkedExprOperation.pushInt], ints: [0]); |
7616 } | 7614 } |
7617 | 7615 |
7618 test_field_final_notConstExpr() { | 7616 test_field_final_notConstExpr() { |
7619 UnlinkedVariable variable = serializeClassText(r''' | 7617 UnlinkedVariable variable = serializeClassText(r''' |
7620 class C { | 7618 class C { |
7621 final int f = 1 + m(); | 7619 final int f = 1 + m(); |
7622 static int m() => 42; | 7620 static int m() => 42; |
7623 }''').fields[0]; | 7621 }''').fields[0]; |
7624 expect(variable.isFinal, isTrue); | 7622 expect(variable.isFinal, isTrue); |
7625 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7623 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7626 isValidConst: false, | 7624 isValidConst: false, |
7627 operators: [ | 7625 operators: [ |
7628 UnlinkedConstOperation.pushInt, | 7626 UnlinkedExprOperation.pushInt, |
7629 UnlinkedConstOperation.invokeMethodRef, | 7627 UnlinkedExprOperation.invokeMethodRef, |
7630 UnlinkedConstOperation.add, | 7628 UnlinkedExprOperation.add, |
7631 ], | 7629 ], |
7632 ints: [ | 7630 ints: [ |
7633 1, | 7631 1, |
7634 0, | 7632 0, |
7635 0, | 7633 0, |
7636 0 | 7634 0 |
7637 ], | 7635 ], |
7638 strings: [], | 7636 strings: [], |
7639 referenceValidators: [ | 7637 referenceValidators: [ |
7640 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 7638 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
7641 expectedKind: ReferenceKind.method, | 7639 expectedKind: ReferenceKind.method, |
7642 prefixExpectations: [ | 7640 prefixExpectations: [ |
7643 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 7641 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
7644 ]) | 7642 ]) |
7645 ]); | 7643 ]); |
7646 } | 7644 } |
7647 | 7645 |
7648 test_field_final_typeParameter() { | 7646 test_field_final_typeParameter() { |
7649 UnlinkedVariable variable = serializeClassText(r''' | 7647 UnlinkedVariable variable = serializeClassText(r''' |
7650 class C<T> { | 7648 class C<T> { |
7651 final f = <T>[]; | 7649 final f = <T>[]; |
7652 }''').fields[0]; | 7650 }''').fields[0]; |
7653 expect(variable.isFinal, isTrue); | 7651 expect(variable.isFinal, isTrue); |
7654 _assertUnlinkedConst(variable.initializer.bodyExpr, | 7652 _assertUnlinkedConst(variable.initializer.bodyExpr, |
7655 operators: [UnlinkedConstOperation.makeTypedList], | 7653 operators: [UnlinkedExprOperation.makeTypedList], |
7656 ints: [0], | 7654 ints: [0], |
7657 referenceValidators: [(EntityRef r) => checkParamTypeRef(r, 1)]); | 7655 referenceValidators: [(EntityRef r) => checkParamTypeRef(r, 1)]); |
7658 } | 7656 } |
7659 | 7657 |
7660 test_field_formal_param_inferred_type_explicit() { | 7658 test_field_formal_param_inferred_type_explicit() { |
7661 UnlinkedClass cls = serializeClassText( | 7659 UnlinkedClass cls = serializeClassText( |
7662 'class C extends D { var v; C(int this.v); }' | 7660 'class C extends D { var v; C(int this.v); }' |
7663 ' abstract class D { num get v; }', | 7661 ' abstract class D { num get v; }', |
7664 className: 'C'); | 7662 className: 'C'); |
7665 checkInferredTypeSlot( | 7663 checkInferredTypeSlot( |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8679 'const a = null; @a class C = D with E; class D {} class E {}', | 8677 'const a = null; @a class C = D with E; class D {} class E {}', |
8680 className: 'C') | 8678 className: 'C') |
8681 .annotations); | 8679 .annotations); |
8682 } | 8680 } |
8683 | 8681 |
8684 test_metadata_constructor_call_named() { | 8682 test_metadata_constructor_call_named() { |
8685 UnlinkedClass cls = serializeClassText( | 8683 UnlinkedClass cls = serializeClassText( |
8686 'class A { const A.named(); } @A.named() class C {}'); | 8684 'class A { const A.named(); } @A.named() class C {}'); |
8687 expect(cls.annotations, hasLength(1)); | 8685 expect(cls.annotations, hasLength(1)); |
8688 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8686 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8689 UnlinkedConstOperation.invokeConstructor, | 8687 UnlinkedExprOperation.invokeConstructor, |
8690 ], ints: [ | 8688 ], ints: [ |
8691 0, | 8689 0, |
8692 0 | 8690 0 |
8693 ], referenceValidators: [ | 8691 ], referenceValidators: [ |
8694 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8692 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8695 expectedKind: ReferenceKind.constructor, | 8693 expectedKind: ReferenceKind.constructor, |
8696 prefixExpectations: [ | 8694 prefixExpectations: [ |
8697 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') | 8695 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') |
8698 ]) | 8696 ]) |
8699 ]); | 8697 ]); |
8700 } | 8698 } |
8701 | 8699 |
8702 test_metadata_constructor_call_named_prefixed() { | 8700 test_metadata_constructor_call_named_prefixed() { |
8703 addNamedSource('/foo.dart', 'class A { const A.named(); }'); | 8701 addNamedSource('/foo.dart', 'class A { const A.named(); }'); |
8704 UnlinkedClass cls = serializeClassText( | 8702 UnlinkedClass cls = serializeClassText( |
8705 'import "foo.dart" as foo; @foo.A.named() class C {}'); | 8703 'import "foo.dart" as foo; @foo.A.named() class C {}'); |
8706 expect(cls.annotations, hasLength(1)); | 8704 expect(cls.annotations, hasLength(1)); |
8707 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8705 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8708 UnlinkedConstOperation.invokeConstructor, | 8706 UnlinkedExprOperation.invokeConstructor, |
8709 ], ints: [ | 8707 ], ints: [ |
8710 0, | 8708 0, |
8711 0 | 8709 0 |
8712 ], referenceValidators: [ | 8710 ], referenceValidators: [ |
8713 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8711 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8714 expectedKind: ReferenceKind.constructor, | 8712 expectedKind: ReferenceKind.constructor, |
8715 prefixExpectations: [ | 8713 prefixExpectations: [ |
8716 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', | 8714 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', |
8717 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), | 8715 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), |
8718 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 8716 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
8719 ]) | 8717 ]) |
8720 ]); | 8718 ]); |
8721 } | 8719 } |
8722 | 8720 |
8723 test_metadata_constructor_call_named_prefixed_unresolved_class() { | 8721 test_metadata_constructor_call_named_prefixed_unresolved_class() { |
8724 addNamedSource('/foo.dart', ''); | 8722 addNamedSource('/foo.dart', ''); |
8725 UnlinkedClass cls = serializeClassText( | 8723 UnlinkedClass cls = serializeClassText( |
8726 'import "foo.dart" as foo; @foo.A.named() class C {}', | 8724 'import "foo.dart" as foo; @foo.A.named() class C {}', |
8727 allowErrors: true); | 8725 allowErrors: true); |
8728 expect(cls.annotations, hasLength(1)); | 8726 expect(cls.annotations, hasLength(1)); |
8729 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8727 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8730 UnlinkedConstOperation.invokeConstructor, | 8728 UnlinkedExprOperation.invokeConstructor, |
8731 ], ints: [ | 8729 ], ints: [ |
8732 0, | 8730 0, |
8733 0 | 8731 0 |
8734 ], referenceValidators: [ | 8732 ], referenceValidators: [ |
8735 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8733 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8736 expectedKind: ReferenceKind.unresolved, | 8734 expectedKind: ReferenceKind.unresolved, |
8737 prefixExpectations: [ | 8735 prefixExpectations: [ |
8738 new _PrefixExpectation(ReferenceKind.unresolved, 'A'), | 8736 new _PrefixExpectation(ReferenceKind.unresolved, 'A'), |
8739 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 8737 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
8740 ]) | 8738 ]) |
8741 ]); | 8739 ]); |
8742 } | 8740 } |
8743 | 8741 |
8744 test_metadata_constructor_call_named_prefixed_unresolved_constructor() { | 8742 test_metadata_constructor_call_named_prefixed_unresolved_constructor() { |
8745 addNamedSource('/foo.dart', 'class A {}'); | 8743 addNamedSource('/foo.dart', 'class A {}'); |
8746 UnlinkedClass cls = serializeClassText( | 8744 UnlinkedClass cls = serializeClassText( |
8747 'import "foo.dart" as foo; @foo.A.named() class C {}', | 8745 'import "foo.dart" as foo; @foo.A.named() class C {}', |
8748 allowErrors: true); | 8746 allowErrors: true); |
8749 expect(cls.annotations, hasLength(1)); | 8747 expect(cls.annotations, hasLength(1)); |
8750 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8748 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8751 UnlinkedConstOperation.invokeConstructor, | 8749 UnlinkedExprOperation.invokeConstructor, |
8752 ], ints: [ | 8750 ], ints: [ |
8753 0, | 8751 0, |
8754 0 | 8752 0 |
8755 ], referenceValidators: [ | 8753 ], referenceValidators: [ |
8756 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8754 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8757 expectedKind: ReferenceKind.unresolved, | 8755 expectedKind: ReferenceKind.unresolved, |
8758 prefixExpectations: [ | 8756 prefixExpectations: [ |
8759 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', | 8757 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', |
8760 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), | 8758 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), |
8761 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 8759 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
8762 ]) | 8760 ]) |
8763 ]); | 8761 ]); |
8764 } | 8762 } |
8765 | 8763 |
8766 test_metadata_constructor_call_named_unresolved_class() { | 8764 test_metadata_constructor_call_named_unresolved_class() { |
8767 UnlinkedClass cls = | 8765 UnlinkedClass cls = |
8768 serializeClassText('@A.named() class C {}', allowErrors: true); | 8766 serializeClassText('@A.named() class C {}', allowErrors: true); |
8769 expect(cls.annotations, hasLength(1)); | 8767 expect(cls.annotations, hasLength(1)); |
8770 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8768 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8771 UnlinkedConstOperation.invokeConstructor, | 8769 UnlinkedExprOperation.invokeConstructor, |
8772 ], ints: [ | 8770 ], ints: [ |
8773 0, | 8771 0, |
8774 0 | 8772 0 |
8775 ], referenceValidators: [ | 8773 ], referenceValidators: [ |
8776 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8774 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8777 expectedKind: ReferenceKind.unresolved, | 8775 expectedKind: ReferenceKind.unresolved, |
8778 prefixExpectations: [ | 8776 prefixExpectations: [ |
8779 new _PrefixExpectation(ReferenceKind.unresolved, 'A') | 8777 new _PrefixExpectation(ReferenceKind.unresolved, 'A') |
8780 ]) | 8778 ]) |
8781 ]); | 8779 ]); |
8782 } | 8780 } |
8783 | 8781 |
8784 test_metadata_constructor_call_named_unresolved_constructor() { | 8782 test_metadata_constructor_call_named_unresolved_constructor() { |
8785 UnlinkedClass cls = serializeClassText('class A {} @A.named() class C {}', | 8783 UnlinkedClass cls = serializeClassText('class A {} @A.named() class C {}', |
8786 allowErrors: true); | 8784 allowErrors: true); |
8787 expect(cls.annotations, hasLength(1)); | 8785 expect(cls.annotations, hasLength(1)); |
8788 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8786 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8789 UnlinkedConstOperation.invokeConstructor, | 8787 UnlinkedExprOperation.invokeConstructor, |
8790 ], ints: [ | 8788 ], ints: [ |
8791 0, | 8789 0, |
8792 0 | 8790 0 |
8793 ], referenceValidators: [ | 8791 ], referenceValidators: [ |
8794 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8792 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
8795 expectedKind: ReferenceKind.unresolved, | 8793 expectedKind: ReferenceKind.unresolved, |
8796 prefixExpectations: [ | 8794 prefixExpectations: [ |
8797 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') | 8795 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') |
8798 ]) | 8796 ]) |
8799 ]); | 8797 ]); |
8800 } | 8798 } |
8801 | 8799 |
8802 test_metadata_constructor_call_unnamed() { | 8800 test_metadata_constructor_call_unnamed() { |
8803 UnlinkedClass cls = | 8801 UnlinkedClass cls = |
8804 serializeClassText('class A { const A(); } @A() class C {}'); | 8802 serializeClassText('class A { const A(); } @A() class C {}'); |
8805 expect(cls.annotations, hasLength(1)); | 8803 expect(cls.annotations, hasLength(1)); |
8806 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8804 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8807 UnlinkedConstOperation.invokeConstructor, | 8805 UnlinkedExprOperation.invokeConstructor, |
8808 ], ints: [ | 8806 ], ints: [ |
8809 0, | 8807 0, |
8810 0 | 8808 0 |
8811 ], referenceValidators: [ | 8809 ], referenceValidators: [ |
8812 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 8810 (EntityRef r) => checkTypeRef(r, null, null, 'A', |
8813 expectedKind: ReferenceKind.classOrEnum) | 8811 expectedKind: ReferenceKind.classOrEnum) |
8814 ]); | 8812 ]); |
8815 } | 8813 } |
8816 | 8814 |
8817 test_metadata_constructor_call_unnamed_prefixed() { | 8815 test_metadata_constructor_call_unnamed_prefixed() { |
8818 addNamedSource('/foo.dart', 'class A { const A(); }'); | 8816 addNamedSource('/foo.dart', 'class A { const A(); }'); |
8819 UnlinkedClass cls = | 8817 UnlinkedClass cls = |
8820 serializeClassText('import "foo.dart" as foo; @foo.A() class C {}'); | 8818 serializeClassText('import "foo.dart" as foo; @foo.A() class C {}'); |
8821 expect(cls.annotations, hasLength(1)); | 8819 expect(cls.annotations, hasLength(1)); |
8822 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8820 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8823 UnlinkedConstOperation.invokeConstructor, | 8821 UnlinkedExprOperation.invokeConstructor, |
8824 ], ints: [ | 8822 ], ints: [ |
8825 0, | 8823 0, |
8826 0 | 8824 0 |
8827 ], referenceValidators: [ | 8825 ], referenceValidators: [ |
8828 (EntityRef r) => checkTypeRef(r, absUri('/foo.dart'), 'foo.dart', 'A', | 8826 (EntityRef r) => checkTypeRef(r, absUri('/foo.dart'), 'foo.dart', 'A', |
8829 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'foo') | 8827 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'foo') |
8830 ]); | 8828 ]); |
8831 } | 8829 } |
8832 | 8830 |
8833 test_metadata_constructor_call_unnamed_prefixed_unresolved() { | 8831 test_metadata_constructor_call_unnamed_prefixed_unresolved() { |
8834 addNamedSource('/foo.dart', ''); | 8832 addNamedSource('/foo.dart', ''); |
8835 UnlinkedClass cls = serializeClassText( | 8833 UnlinkedClass cls = serializeClassText( |
8836 'import "foo.dart" as foo; @foo.A() class C {}', | 8834 'import "foo.dart" as foo; @foo.A() class C {}', |
8837 allowErrors: true); | 8835 allowErrors: true); |
8838 expect(cls.annotations, hasLength(1)); | 8836 expect(cls.annotations, hasLength(1)); |
8839 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8837 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8840 UnlinkedConstOperation.invokeConstructor, | 8838 UnlinkedExprOperation.invokeConstructor, |
8841 ], ints: [ | 8839 ], ints: [ |
8842 0, | 8840 0, |
8843 0 | 8841 0 |
8844 ], referenceValidators: [ | 8842 ], referenceValidators: [ |
8845 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 8843 (EntityRef r) => checkTypeRef(r, null, null, 'A', |
8846 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'foo') | 8844 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'foo') |
8847 ]); | 8845 ]); |
8848 } | 8846 } |
8849 | 8847 |
8850 test_metadata_constructor_call_unnamed_unresolved() { | 8848 test_metadata_constructor_call_unnamed_unresolved() { |
8851 UnlinkedClass cls = | 8849 UnlinkedClass cls = |
8852 serializeClassText('@A() class C {}', allowErrors: true); | 8850 serializeClassText('@A() class C {}', allowErrors: true); |
8853 expect(cls.annotations, hasLength(1)); | 8851 expect(cls.annotations, hasLength(1)); |
8854 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8852 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8855 UnlinkedConstOperation.invokeConstructor, | 8853 UnlinkedExprOperation.invokeConstructor, |
8856 ], ints: [ | 8854 ], ints: [ |
8857 0, | 8855 0, |
8858 0 | 8856 0 |
8859 ], referenceValidators: [ | 8857 ], referenceValidators: [ |
8860 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 8858 (EntityRef r) => checkTypeRef(r, null, null, 'A', |
8861 expectedKind: ReferenceKind.unresolved) | 8859 expectedKind: ReferenceKind.unresolved) |
8862 ]); | 8860 ]); |
8863 } | 8861 } |
8864 | 8862 |
8865 test_metadata_constructor_call_with_args() { | 8863 test_metadata_constructor_call_with_args() { |
8866 UnlinkedClass cls = | 8864 UnlinkedClass cls = |
8867 serializeClassText('class A { const A(x); } @A(null) class C {}'); | 8865 serializeClassText('class A { const A(x); } @A(null) class C {}'); |
8868 expect(cls.annotations, hasLength(1)); | 8866 expect(cls.annotations, hasLength(1)); |
8869 _assertUnlinkedConst(cls.annotations[0], operators: [ | 8867 _assertUnlinkedConst(cls.annotations[0], operators: [ |
8870 UnlinkedConstOperation.pushNull, | 8868 UnlinkedExprOperation.pushNull, |
8871 UnlinkedConstOperation.invokeConstructor, | 8869 UnlinkedExprOperation.invokeConstructor, |
8872 ], ints: [ | 8870 ], ints: [ |
8873 0, | 8871 0, |
8874 1 | 8872 1 |
8875 ], referenceValidators: [ | 8873 ], referenceValidators: [ |
8876 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 8874 (EntityRef r) => checkTypeRef(r, null, null, 'A', |
8877 expectedKind: ReferenceKind.classOrEnum) | 8875 expectedKind: ReferenceKind.classOrEnum) |
8878 ]); | 8876 ]); |
8879 } | 8877 } |
8880 | 8878 |
8881 test_metadata_constructorDeclaration_named() { | 8879 test_metadata_constructorDeclaration_named() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8987 test_metadata_methodDeclaration_setter() { | 8985 test_metadata_methodDeclaration_setter() { |
8988 checkAnnotationA( | 8986 checkAnnotationA( |
8989 serializeClassText('const a = null; class C { @a set m(value) {} }') | 8987 serializeClassText('const a = null; class C { @a set m(value) {} }') |
8990 .executables[0] | 8988 .executables[0] |
8991 .annotations); | 8989 .annotations); |
8992 } | 8990 } |
8993 | 8991 |
8994 test_metadata_multiple_annotations() { | 8992 test_metadata_multiple_annotations() { |
8995 UnlinkedClass cls = | 8993 UnlinkedClass cls = |
8996 serializeClassText('const a = null, b = null; @a @b class C {}'); | 8994 serializeClassText('const a = null, b = null; @a @b class C {}'); |
8997 List<UnlinkedConst> annotations = cls.annotations; | 8995 List<UnlinkedExpr> annotations = cls.annotations; |
8998 expect(annotations, hasLength(2)); | 8996 expect(annotations, hasLength(2)); |
8999 _assertUnlinkedConst(annotations[0], operators: [ | 8997 _assertUnlinkedConst(annotations[0], operators: [ |
9000 UnlinkedConstOperation.pushReference | 8998 UnlinkedExprOperation.pushReference |
9001 ], referenceValidators: [ | 8999 ], referenceValidators: [ |
9002 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9000 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
9003 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9001 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
9004 ]); | 9002 ]); |
9005 _assertUnlinkedConst(annotations[1], operators: [ | 9003 _assertUnlinkedConst(annotations[1], operators: [ |
9006 UnlinkedConstOperation.pushReference | 9004 UnlinkedExprOperation.pushReference |
9007 ], referenceValidators: [ | 9005 ], referenceValidators: [ |
9008 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 9006 (EntityRef r) => checkTypeRef(r, null, null, 'b', |
9009 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9007 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
9010 ]); | 9008 ]); |
9011 } | 9009 } |
9012 | 9010 |
9013 test_metadata_partDirective() { | 9011 test_metadata_partDirective() { |
9014 addNamedSource('/foo.dart', 'part of L;'); | 9012 addNamedSource('/foo.dart', 'part of L;'); |
9015 serializeLibraryText('library L; @a part "foo.dart"; const a = null;'); | 9013 serializeLibraryText('library L; @a part "foo.dart"; const a = null;'); |
9016 checkAnnotationA(unlinkedUnits[0].parts[0].annotations); | 9014 checkAnnotationA(unlinkedUnits[0].parts[0].annotations); |
9017 } | 9015 } |
9018 | 9016 |
9019 test_metadata_prefixed_variable() { | 9017 test_metadata_prefixed_variable() { |
9020 addNamedSource('/a.dart', 'const b = null;'); | 9018 addNamedSource('/a.dart', 'const b = null;'); |
9021 UnlinkedClass cls = | 9019 UnlinkedClass cls = |
9022 serializeClassText('import "a.dart" as a; @a.b class C {}'); | 9020 serializeClassText('import "a.dart" as a; @a.b class C {}'); |
9023 expect(cls.annotations, hasLength(1)); | 9021 expect(cls.annotations, hasLength(1)); |
9024 _assertUnlinkedConst(cls.annotations[0], operators: [ | 9022 _assertUnlinkedConst(cls.annotations[0], operators: [ |
9025 UnlinkedConstOperation.pushReference | 9023 UnlinkedExprOperation.pushReference |
9026 ], referenceValidators: [ | 9024 ], referenceValidators: [ |
9027 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'b', | 9025 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'b', |
9028 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 9026 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
9029 expectedPrefix: 'a') | 9027 expectedPrefix: 'a') |
9030 ]); | 9028 ]); |
9031 } | 9029 } |
9032 | 9030 |
9033 test_metadata_prefixed_variable_unresolved() { | 9031 test_metadata_prefixed_variable_unresolved() { |
9034 addNamedSource('/a.dart', ''); | 9032 addNamedSource('/a.dart', ''); |
9035 UnlinkedClass cls = serializeClassText( | 9033 UnlinkedClass cls = serializeClassText( |
9036 'import "a.dart" as a; @a.b class C {}', | 9034 'import "a.dart" as a; @a.b class C {}', |
9037 allowErrors: true); | 9035 allowErrors: true); |
9038 expect(cls.annotations, hasLength(1)); | 9036 expect(cls.annotations, hasLength(1)); |
9039 _assertUnlinkedConst(cls.annotations[0], operators: [ | 9037 _assertUnlinkedConst(cls.annotations[0], operators: [ |
9040 UnlinkedConstOperation.pushReference | 9038 UnlinkedExprOperation.pushReference |
9041 ], referenceValidators: [ | 9039 ], referenceValidators: [ |
9042 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 9040 (EntityRef r) => checkTypeRef(r, null, null, 'b', |
9043 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'a') | 9041 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'a') |
9044 ]); | 9042 ]); |
9045 } | 9043 } |
9046 | 9044 |
9047 test_metadata_simpleFormalParameter() { | 9045 test_metadata_simpleFormalParameter() { |
9048 checkAnnotationA(serializeExecutableText('const a = null; f(@a x) {}') | 9046 checkAnnotationA(serializeExecutableText('const a = null; f(@a x) {}') |
9049 .parameters[0] | 9047 .parameters[0] |
9050 .annotations); | 9048 .annotations); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9085 test_metadata_typeParameter_ofTypedef() { | 9083 test_metadata_typeParameter_ofTypedef() { |
9086 checkAnnotationA(serializeTypedefText('const a = null; typedef F<@a T>();') | 9084 checkAnnotationA(serializeTypedefText('const a = null; typedef F<@a T>();') |
9087 .typeParameters[0] | 9085 .typeParameters[0] |
9088 .annotations); | 9086 .annotations); |
9089 } | 9087 } |
9090 | 9088 |
9091 test_metadata_variable_unresolved() { | 9089 test_metadata_variable_unresolved() { |
9092 UnlinkedClass cls = serializeClassText('@a class C {}', allowErrors: true); | 9090 UnlinkedClass cls = serializeClassText('@a class C {}', allowErrors: true); |
9093 expect(cls.annotations, hasLength(1)); | 9091 expect(cls.annotations, hasLength(1)); |
9094 _assertUnlinkedConst(cls.annotations[0], operators: [ | 9092 _assertUnlinkedConst(cls.annotations[0], operators: [ |
9095 UnlinkedConstOperation.pushReference | 9093 UnlinkedExprOperation.pushReference |
9096 ], referenceValidators: [ | 9094 ], referenceValidators: [ |
9097 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9095 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
9098 expectedKind: ReferenceKind.unresolved) | 9096 expectedKind: ReferenceKind.unresolved) |
9099 ]); | 9097 ]); |
9100 } | 9098 } |
9101 | 9099 |
9102 test_method_documented() { | 9100 test_method_documented() { |
9103 String text = ''' | 9101 String text = ''' |
9104 class C { | 9102 class C { |
9105 /** | 9103 /** |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10230 if (skipNonConstInitializers) { | 10228 if (skipNonConstInitializers) { |
10231 return; | 10229 return; |
10232 } | 10230 } |
10233 UnlinkedVariable variable = serializeVariableText(''' | 10231 UnlinkedVariable variable = serializeVariableText(''' |
10234 int a = 0; | 10232 int a = 0; |
10235 final v = $expr; | 10233 final v = $expr; |
10236 '''); | 10234 '''); |
10237 _assertUnlinkedConst(variable.initializer.bodyExpr, | 10235 _assertUnlinkedConst(variable.initializer.bodyExpr, |
10238 isValidConst: false, | 10236 isValidConst: false, |
10239 operators: [ | 10237 operators: [ |
10240 UnlinkedConstOperation.pushInt, | 10238 UnlinkedExprOperation.pushInt, |
10241 UnlinkedConstOperation.pushInt, | 10239 UnlinkedExprOperation.pushInt, |
10242 UnlinkedConstOperation.add, | 10240 UnlinkedExprOperation.add, |
10243 UnlinkedConstOperation.assignToRef, | 10241 UnlinkedExprOperation.assignToRef, |
10244 UnlinkedConstOperation.pushInt, | 10242 UnlinkedExprOperation.pushInt, |
10245 UnlinkedConstOperation.add, | 10243 UnlinkedExprOperation.add, |
10246 ], | 10244 ], |
10247 assignmentOperators: [ | 10245 assignmentOperators: [ |
10248 expectedAssignOperator | 10246 expectedAssignOperator |
10249 ], | 10247 ], |
10250 ints: [ | 10248 ints: [ |
10251 1, | 10249 1, |
10252 2, | 10250 2, |
10253 3 | 10251 3 |
10254 ], | 10252 ], |
10255 strings: [], | 10253 strings: [], |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10297 if (skipNonConstInitializers) { | 10295 if (skipNonConstInitializers) { |
10298 return; | 10296 return; |
10299 } | 10297 } |
10300 UnlinkedVariable variable = serializeVariableText(''' | 10298 UnlinkedVariable variable = serializeVariableText(''' |
10301 int a = 0; | 10299 int a = 0; |
10302 final v = $expr; | 10300 final v = $expr; |
10303 '''); | 10301 '''); |
10304 _assertUnlinkedConst(variable.initializer.bodyExpr, | 10302 _assertUnlinkedConst(variable.initializer.bodyExpr, |
10305 isValidConst: false, | 10303 isValidConst: false, |
10306 operators: [ | 10304 operators: [ |
10307 UnlinkedConstOperation.assignToRef, | 10305 UnlinkedExprOperation.assignToRef, |
10308 UnlinkedConstOperation.pushInt, | 10306 UnlinkedExprOperation.pushInt, |
10309 UnlinkedConstOperation.add, | 10307 UnlinkedExprOperation.add, |
10310 ], | 10308 ], |
10311 assignmentOperators: [ | 10309 assignmentOperators: [ |
10312 expectedAssignmentOperator | 10310 expectedAssignmentOperator |
10313 ], | 10311 ], |
10314 ints: [ | 10312 ints: [ |
10315 2 | 10313 2 |
10316 ], | 10314 ], |
10317 strings: [], | 10315 strings: [], |
10318 referenceValidators: [ | 10316 referenceValidators: [ |
10319 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 10317 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
10320 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 10318 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
10321 ]); | 10319 ]); |
10322 } | 10320 } |
10323 | 10321 |
10324 /** | 10322 /** |
10325 * TODO(scheglov) rename "Const" to "Expr" everywhere | 10323 * TODO(scheglov) rename "Const" to "Expr" everywhere |
10326 */ | 10324 */ |
10327 void _assertUnlinkedConst(UnlinkedConst constExpr, | 10325 void _assertUnlinkedConst(UnlinkedExpr constExpr, |
10328 {bool isValidConst: true, | 10326 {bool isValidConst: true, |
10329 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], | 10327 List<UnlinkedExprOperation> operators: const <UnlinkedExprOperation>[], |
10330 List<UnlinkedExprAssignOperator> assignmentOperators: | 10328 List<UnlinkedExprAssignOperator> assignmentOperators: |
10331 const <UnlinkedExprAssignOperator>[], | 10329 const <UnlinkedExprAssignOperator>[], |
10332 List<int> ints: const <int>[], | 10330 List<int> ints: const <int>[], |
10333 List<double> doubles: const <double>[], | 10331 List<double> doubles: const <double>[], |
10334 List<String> strings: const <String>[], | 10332 List<String> strings: const <String>[], |
10335 List<_EntityRefValidator> referenceValidators: | 10333 List<_EntityRefValidator> referenceValidators: |
10336 const <_EntityRefValidator>[]}) { | 10334 const <_EntityRefValidator>[]}) { |
10337 expect(constExpr, isNotNull); | 10335 expect(constExpr, isNotNull); |
10338 expect(constExpr.isValidConst, isValidConst); | 10336 expect(constExpr.isValidConst, isValidConst); |
10339 expect(constExpr.operations, operators); | 10337 expect(constExpr.operations, operators); |
(...skipping 23 matching lines...) Expand all Loading... |
10363 class _PrefixExpectation { | 10361 class _PrefixExpectation { |
10364 final ReferenceKind kind; | 10362 final ReferenceKind kind; |
10365 final String name; | 10363 final String name; |
10366 final String absoluteUri; | 10364 final String absoluteUri; |
10367 final String relativeUri; | 10365 final String relativeUri; |
10368 final int numTypeParameters; | 10366 final int numTypeParameters; |
10369 | 10367 |
10370 _PrefixExpectation(this.kind, this.name, | 10368 _PrefixExpectation(this.kind, this.name, |
10371 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10369 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
10372 } | 10370 } |
OLD | NEW |