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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1658253002: Serialize constant instance creation of generic classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove the special case for unnamed constructors from _getElementReferenceId(). Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 serializeVariableText('const v = identical(42, null);'); 1545 serializeVariableText('const v = identical(42, null);');
1546 _assertUnlinkedConst(variable.constExpr, operators: [ 1546 _assertUnlinkedConst(variable.constExpr, operators: [
1547 UnlinkedConstOperation.pushInt, 1547 UnlinkedConstOperation.pushInt,
1548 UnlinkedConstOperation.pushNull, 1548 UnlinkedConstOperation.pushNull,
1549 UnlinkedConstOperation.identical 1549 UnlinkedConstOperation.identical
1550 ], ints: [ 1550 ], ints: [
1551 42 1551 42
1552 ]); 1552 ]);
1553 } 1553 }
1554 1554
1555 test_constExpr_invokeConstructor_generic_named() {
1556 UnlinkedVariable variable = serializeVariableText('''
1557 class C<K, V> {
1558 const C.named();
1559 }
1560 const v = const C<int, String>.named();
1561 ''');
1562 _assertUnlinkedConst(variable.constExpr, operators: [
1563 UnlinkedConstOperation.invokeConstructor,
1564 ], ints: [
1565 0,
1566 0
1567 ], referenceValidators: [
1568 (EntityRef r) {
1569 checkTypeRef(r, null, null, 'named',
1570 expectedKind: ReferenceKind.constructor,
1571 prefixExpectations: [
1572 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
1573 numTypeParameters: 2)
1574 ],
1575 allowTypeParameters: true);
1576 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1577 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1578 }
1579 ]);
1580 }
1581
1582 test_constExpr_invokeConstructor_generic_named_imported() {
1583 addNamedSource(
1584 '/a.dart',
1585 '''
1586 class C<K, V> {
1587 const C.named();
1588 }
1589 ''');
1590 UnlinkedVariable variable = serializeVariableText('''
1591 import 'a.dart';
1592 const v = const C<int, String>.named();
1593 ''');
1594 _assertUnlinkedConst(variable.constExpr, operators: [
1595 UnlinkedConstOperation.invokeConstructor,
1596 ], ints: [
1597 0,
1598 0
1599 ], referenceValidators: [
1600 (EntityRef r) {
1601 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
1602 expectedKind: ReferenceKind.constructor,
1603 prefixExpectations: [
1604 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
1605 numTypeParameters: 2)
1606 ],
1607 allowTypeParameters: true);
1608 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1609 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1610 }
1611 ]);
1612 }
1613
1614 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() {
1615 addNamedSource(
1616 '/a.dart',
1617 '''
1618 class C<K, V> {
1619 const C.named();
1620 }
1621 ''');
1622 UnlinkedVariable variable = serializeVariableText('''
1623 import 'a.dart' as p;
1624 const v = const p.C<int, String>.named();
1625 ''');
1626 _assertUnlinkedConst(variable.constExpr, operators: [
1627 UnlinkedConstOperation.invokeConstructor,
1628 ], ints: [
1629 0,
1630 0
1631 ], referenceValidators: [
1632 (EntityRef r) {
1633 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
1634 expectedKind: ReferenceKind.constructor,
1635 prefixExpectations: [
1636 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
1637 numTypeParameters: 2),
1638 new _PrefixExpectation(ReferenceKind.prefix, 'p',
1639 inLibraryDefiningUnit: true)
1640 ],
1641 allowTypeParameters: true);
1642 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1643 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1644 }
1645 ]);
1646 }
1647
1648 test_constExpr_invokeConstructor_generic_unnamed() {
1649 UnlinkedVariable variable = serializeVariableText('''
1650 class C<K, V> {
1651 const C();
1652 }
1653 const v = const C<int, String>();
1654 ''');
1655 _assertUnlinkedConst(variable.constExpr, operators: [
1656 UnlinkedConstOperation.invokeConstructor,
1657 ], ints: [
1658 0,
1659 0
1660 ], referenceValidators: [
1661 (EntityRef r) {
1662 checkTypeRef(r, null, null, 'C',
1663 expectedKind: ReferenceKind.classOrEnum,
1664 numTypeParameters: 2,
1665 allowTypeParameters: true);
1666 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1667 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1668 }
1669 ]);
1670 }
1671
1672 test_constExpr_invokeConstructor_generic_unnamed_imported() {
1673 addNamedSource(
1674 '/a.dart',
1675 '''
1676 class C<K, V> {
1677 const C();
1678 }
1679 ''');
1680 UnlinkedVariable variable = serializeVariableText('''
1681 import 'a.dart';
1682 const v = const C<int, String>();
1683 ''');
1684 _assertUnlinkedConst(variable.constExpr, operators: [
1685 UnlinkedConstOperation.invokeConstructor,
1686 ], ints: [
1687 0,
1688 0
1689 ], referenceValidators: [
1690 (EntityRef r) {
1691 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1692 expectedKind: ReferenceKind.classOrEnum,
1693 numTypeParameters: 2,
1694 allowTypeParameters: true);
1695 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1696 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1697 }
1698 ]);
1699 }
1700
1701 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() {
1702 addNamedSource(
1703 '/a.dart',
1704 '''
1705 class C<K, V> {
1706 const C();
1707 }
1708 ''');
1709 UnlinkedVariable variable = serializeVariableText('''
1710 import 'a.dart' as p;
1711 const v = const p.C<int, String>();
1712 ''');
1713 _assertUnlinkedConst(variable.constExpr, operators: [
1714 UnlinkedConstOperation.invokeConstructor,
1715 ], ints: [
1716 0,
1717 0
1718 ], referenceValidators: [
1719 (EntityRef r) {
1720 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1721 expectedKind: ReferenceKind.classOrEnum,
1722 numTypeParameters: 2,
1723 allowTypeParameters: true,
1724 prefixExpectations: [
1725 new _PrefixExpectation(ReferenceKind.prefix, 'p',
1726 inLibraryDefiningUnit: true)
1727 ]);
1728 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
1729 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
1730 }
1731 ]);
1732 }
1733
1555 test_constExpr_invokeConstructor_named() { 1734 test_constExpr_invokeConstructor_named() {
1556 UnlinkedVariable variable = serializeVariableText(''' 1735 UnlinkedVariable variable = serializeVariableText('''
1557 class C { 1736 class C {
1558 const C.named(); 1737 const C.named();
1559 } 1738 }
1560 const v = const C.named(); 1739 const v = const C.named();
1561 '''); 1740 ''');
1562 _assertUnlinkedConst(variable.constExpr, operators: [ 1741 _assertUnlinkedConst(variable.constExpr, operators: [
1563 UnlinkedConstOperation.invokeConstructor, 1742 UnlinkedConstOperation.invokeConstructor,
1564 ], ints: [ 1743 ], ints: [
(...skipping 3517 matching lines...) Expand 10 before | Expand all | Expand 10 after
5082 final String absoluteUri; 5261 final String absoluteUri;
5083 final String relativeUri; 5262 final String relativeUri;
5084 final int numTypeParameters; 5263 final int numTypeParameters;
5085 5264
5086 _PrefixExpectation(this.kind, this.name, 5265 _PrefixExpectation(this.kind, this.name,
5087 {this.inLibraryDefiningUnit: false, 5266 {this.inLibraryDefiningUnit: false,
5088 this.absoluteUri, 5267 this.absoluteUri,
5089 this.relativeUri, 5268 this.relativeUri,
5090 this.numTypeParameters: 0}); 5269 this.numTypeParameters: 0});
5091 } 5270 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698