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/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 expect(referenceResolution.unit, expectedTargetUnit); | 566 expect(referenceResolution.unit, expectedTargetUnit); |
567 expect(referenceResolution.numTypeParameters, numTypeParameters); | 567 expect(referenceResolution.numTypeParameters, numTypeParameters); |
568 expect(referenceResolution.localIndex, localIndex); | 568 expect(referenceResolution.localIndex, localIndex); |
569 return reference; | 569 return reference; |
570 } | 570 } |
571 | 571 |
572 /** | 572 /** |
573 * Verify that the given [typeRef] represents a reference to a type declared | 573 * Verify that the given [typeRef] represents a reference to a type declared |
574 * in a file reachable via [absoluteUri] and [relativeUri], having name | 574 * in a file reachable via [absoluteUri] and [relativeUri], having name |
575 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is | 575 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is |
576 * reached via the given prefix. If [allowTypeParameters] is true, allow the | 576 * reached via the given prefix. If [allowTypeArguments] is true, allow the |
Paul Berry
2016/05/05 17:25:01
This sentence isn't accurate--there's no "allowTyp
| |
577 * type reference to supply type parameters. [expectedKind] is the kind of | 577 * type reference to supply type arguments. [expectedKind] is the kind of |
578 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer | 578 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer |
579 * to the compilation unit within which the [typeRef] appears; if not | 579 * to the compilation unit within which the [typeRef] appears; if not |
580 * specified they are assumed to refer to the defining compilation unit. | 580 * specified they are assumed to refer to the defining compilation unit. |
581 * [expectedTargetUnit] is the index of the compilation unit in which the | 581 * [expectedTargetUnit] is the index of the compilation unit in which the |
582 * target of the [typeRef] is expected to appear; if not specified it is | 582 * target of the [typeRef] is expected to appear; if not specified it is |
583 * assumed to be the defining compilation unit. [numTypeParameters] is the | 583 * assumed to be the defining compilation unit. [numTypeParameters] is the |
584 * number of type parameters of the thing being referred to. | 584 * number of type parameters of the thing being referred to. |
585 * | 585 * |
586 * TODO(scheglov) remove [checkAstDerivedDataOverride] once elements-based | 586 * TODO(scheglov) remove [checkAstDerivedDataOverride] once elements-based |
587 * serializer can record unresolved information. | 587 * serializer can record unresolved information. |
588 */ | 588 */ |
589 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri, | 589 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri, |
590 String expectedName, | 590 String expectedName, |
591 {String expectedPrefix, | 591 {String expectedPrefix, |
592 List<_PrefixExpectation> prefixExpectations, | 592 List<_PrefixExpectation> prefixExpectations, |
593 bool allowTypeParameters: false, | 593 int numTypeArguments: 0, |
594 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 594 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
595 int expectedTargetUnit: 0, | 595 int expectedTargetUnit: 0, |
596 LinkedUnit linkedSourceUnit, | 596 LinkedUnit linkedSourceUnit, |
597 UnlinkedUnit unlinkedSourceUnit, | 597 UnlinkedUnit unlinkedSourceUnit, |
598 int numTypeParameters: 0, | 598 int numTypeParameters: 0, |
599 bool checkAstDerivedDataOverride: false, | 599 bool checkAstDerivedDataOverride: false, |
600 bool unresolvedHasName: false}) { | 600 bool unresolvedHasName: false}) { |
601 linkedSourceUnit ??= definingUnit; | 601 linkedSourceUnit ??= definingUnit; |
602 expect(typeRef, new isInstanceOf<EntityRef>()); | 602 expect(typeRef, new isInstanceOf<EntityRef>()); |
603 expect(typeRef.paramReference, 0); | 603 expect(typeRef.paramReference, 0); |
604 int index = typeRef.reference; | 604 int index = typeRef.reference; |
605 if (!allowTypeParameters) { | 605 expect(typeRef.typeArguments, hasLength(numTypeArguments)); |
606 expect(typeRef.typeArguments, isEmpty); | |
607 } | |
608 UnlinkedReference reference = checkReferenceIndex( | 606 UnlinkedReference reference = checkReferenceIndex( |
609 index, absoluteUri, relativeUri, expectedName, | 607 index, absoluteUri, relativeUri, expectedName, |
610 expectedKind: expectedKind, | 608 expectedKind: expectedKind, |
611 expectedTargetUnit: expectedTargetUnit, | 609 expectedTargetUnit: expectedTargetUnit, |
612 linkedSourceUnit: linkedSourceUnit, | 610 linkedSourceUnit: linkedSourceUnit, |
613 unlinkedSourceUnit: unlinkedSourceUnit, | 611 unlinkedSourceUnit: unlinkedSourceUnit, |
614 numTypeParameters: numTypeParameters, | 612 numTypeParameters: numTypeParameters, |
615 checkAstDerivedDataOverride: checkAstDerivedDataOverride, | 613 checkAstDerivedDataOverride: checkAstDerivedDataOverride, |
616 unresolvedHasName: unresolvedHasName); | 614 unresolvedHasName: unresolvedHasName); |
617 expect(reference, isNotNull, | 615 expect(reference, isNotNull, |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1343 checkTypeRef(cls.supertype, null, null, 'D'); | 1341 checkTypeRef(cls.supertype, null, null, 'D'); |
1344 expect(cls.hasNoSupertype, isFalse); | 1342 expect(cls.hasNoSupertype, isFalse); |
1345 } | 1343 } |
1346 | 1344 |
1347 test_class_type_param_bound() { | 1345 test_class_type_param_bound() { |
1348 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); | 1346 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); |
1349 expect(cls.typeParameters, hasLength(1)); | 1347 expect(cls.typeParameters, hasLength(1)); |
1350 expect(cls.typeParameters[0].name, 'T'); | 1348 expect(cls.typeParameters[0].name, 'T'); |
1351 expect(cls.typeParameters[0].bound, isNotNull); | 1349 expect(cls.typeParameters[0].bound, isNotNull); |
1352 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', | 1350 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', |
1353 allowTypeParameters: true, numTypeParameters: 1); | 1351 numTypeParameters: 1); |
1354 } | 1352 } |
1355 | 1353 |
1356 test_class_type_param_f_bound() { | 1354 test_class_type_param_f_bound() { |
1357 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); | 1355 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); |
1358 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; | 1356 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; |
1359 checkParamTypeRef(typeArgument, 2); | 1357 checkParamTypeRef(typeArgument, 2); |
1360 } | 1358 } |
1361 | 1359 |
1362 test_class_type_param_f_bound_self_ref() { | 1360 test_class_type_param_f_bound_self_ref() { |
1363 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); | 1361 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1758 0, | 1756 0, |
1759 0 | 1757 0 |
1760 ], referenceValidators: [ | 1758 ], referenceValidators: [ |
1761 (EntityRef r) { | 1759 (EntityRef r) { |
1762 checkTypeRef(r, null, null, 'named', | 1760 checkTypeRef(r, null, null, 'named', |
1763 expectedKind: ReferenceKind.constructor, | 1761 expectedKind: ReferenceKind.constructor, |
1764 prefixExpectations: [ | 1762 prefixExpectations: [ |
1765 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1763 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1766 numTypeParameters: 2) | 1764 numTypeParameters: 2) |
1767 ], | 1765 ], |
1768 allowTypeParameters: true); | 1766 numTypeArguments: 2); |
1769 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1767 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1770 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1768 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1771 } | 1769 } |
1772 ]); | 1770 ]); |
1773 } | 1771 } |
1774 | 1772 |
1775 test_constExpr_invokeConstructor_generic_named_imported() { | 1773 test_constExpr_invokeConstructor_generic_named_imported() { |
1776 addNamedSource( | 1774 addNamedSource( |
1777 '/a.dart', | 1775 '/a.dart', |
1778 ''' | 1776 ''' |
(...skipping 13 matching lines...) Expand all Loading... | |
1792 ], referenceValidators: [ | 1790 ], referenceValidators: [ |
1793 (EntityRef r) { | 1791 (EntityRef r) { |
1794 checkTypeRef(r, null, null, 'named', | 1792 checkTypeRef(r, null, null, 'named', |
1795 expectedKind: ReferenceKind.constructor, | 1793 expectedKind: ReferenceKind.constructor, |
1796 prefixExpectations: [ | 1794 prefixExpectations: [ |
1797 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1795 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1798 absoluteUri: absUri('/a.dart'), | 1796 absoluteUri: absUri('/a.dart'), |
1799 relativeUri: 'a.dart', | 1797 relativeUri: 'a.dart', |
1800 numTypeParameters: 2) | 1798 numTypeParameters: 2) |
1801 ], | 1799 ], |
1802 allowTypeParameters: true); | 1800 numTypeArguments: 2); |
1803 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1801 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1804 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1802 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1805 } | 1803 } |
1806 ]); | 1804 ]); |
1807 } | 1805 } |
1808 | 1806 |
1809 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { | 1807 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { |
1810 addNamedSource( | 1808 addNamedSource( |
1811 '/a.dart', | 1809 '/a.dart', |
1812 ''' | 1810 ''' |
(...skipping 14 matching lines...) Expand all Loading... | |
1827 (EntityRef r) { | 1825 (EntityRef r) { |
1828 checkTypeRef(r, null, null, 'named', | 1826 checkTypeRef(r, null, null, 'named', |
1829 expectedKind: ReferenceKind.constructor, | 1827 expectedKind: ReferenceKind.constructor, |
1830 prefixExpectations: [ | 1828 prefixExpectations: [ |
1831 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1829 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
1832 absoluteUri: absUri('/a.dart'), | 1830 absoluteUri: absUri('/a.dart'), |
1833 relativeUri: 'a.dart', | 1831 relativeUri: 'a.dart', |
1834 numTypeParameters: 2), | 1832 numTypeParameters: 2), |
1835 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 1833 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
1836 ], | 1834 ], |
1837 allowTypeParameters: true); | 1835 numTypeArguments: 2); |
1838 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1836 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1839 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1837 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1840 } | 1838 } |
1841 ]); | 1839 ]); |
1842 } | 1840 } |
1843 | 1841 |
1844 test_constExpr_invokeConstructor_generic_unnamed() { | 1842 test_constExpr_invokeConstructor_generic_unnamed() { |
1845 UnlinkedVariable variable = serializeVariableText(''' | 1843 UnlinkedVariable variable = serializeVariableText(''' |
1846 class C<K, V> { | 1844 class C<K, V> { |
1847 const C(); | 1845 const C(); |
1848 } | 1846 } |
1849 const v = const C<int, String>(); | 1847 const v = const C<int, String>(); |
1850 '''); | 1848 '''); |
1851 _assertUnlinkedConst(variable.constExpr, operators: [ | 1849 _assertUnlinkedConst(variable.constExpr, operators: [ |
1852 UnlinkedConstOperation.invokeConstructor, | 1850 UnlinkedConstOperation.invokeConstructor, |
1853 ], ints: [ | 1851 ], ints: [ |
1854 0, | 1852 0, |
1855 0 | 1853 0 |
1856 ], referenceValidators: [ | 1854 ], referenceValidators: [ |
1857 (EntityRef r) { | 1855 (EntityRef r) { |
1858 checkTypeRef(r, null, null, 'C', | 1856 checkTypeRef(r, null, null, 'C', |
1859 expectedKind: ReferenceKind.classOrEnum, | 1857 expectedKind: ReferenceKind.classOrEnum, |
1860 numTypeParameters: 2, | 1858 numTypeParameters: 2, |
1861 allowTypeParameters: true); | 1859 numTypeArguments: 2); |
1862 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1860 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1863 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1861 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1864 } | 1862 } |
1865 ]); | 1863 ]); |
1866 } | 1864 } |
1867 | 1865 |
1868 test_constExpr_invokeConstructor_generic_unnamed_imported() { | 1866 test_constExpr_invokeConstructor_generic_unnamed_imported() { |
1869 addNamedSource( | 1867 addNamedSource( |
1870 '/a.dart', | 1868 '/a.dart', |
1871 ''' | 1869 ''' |
1872 class C<K, V> { | 1870 class C<K, V> { |
1873 const C(); | 1871 const C(); |
1874 } | 1872 } |
1875 '''); | 1873 '''); |
1876 UnlinkedVariable variable = serializeVariableText(''' | 1874 UnlinkedVariable variable = serializeVariableText(''' |
1877 import 'a.dart'; | 1875 import 'a.dart'; |
1878 const v = const C<int, String>(); | 1876 const v = const C<int, String>(); |
1879 '''); | 1877 '''); |
1880 _assertUnlinkedConst(variable.constExpr, operators: [ | 1878 _assertUnlinkedConst(variable.constExpr, operators: [ |
1881 UnlinkedConstOperation.invokeConstructor, | 1879 UnlinkedConstOperation.invokeConstructor, |
1882 ], ints: [ | 1880 ], ints: [ |
1883 0, | 1881 0, |
1884 0 | 1882 0 |
1885 ], referenceValidators: [ | 1883 ], referenceValidators: [ |
1886 (EntityRef r) { | 1884 (EntityRef r) { |
1887 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 1885 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
1888 expectedKind: ReferenceKind.classOrEnum, | 1886 expectedKind: ReferenceKind.classOrEnum, |
1889 numTypeParameters: 2, | 1887 numTypeParameters: 2, |
1890 allowTypeParameters: true); | 1888 numTypeArguments: 2); |
1891 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1889 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1892 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1890 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1893 } | 1891 } |
1894 ]); | 1892 ]); |
1895 } | 1893 } |
1896 | 1894 |
1897 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { | 1895 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { |
1898 addNamedSource( | 1896 addNamedSource( |
1899 '/a.dart', | 1897 '/a.dart', |
1900 ''' | 1898 ''' |
1901 class C<K, V> { | 1899 class C<K, V> { |
1902 const C(); | 1900 const C(); |
1903 } | 1901 } |
1904 '''); | 1902 '''); |
1905 UnlinkedVariable variable = serializeVariableText(''' | 1903 UnlinkedVariable variable = serializeVariableText(''' |
1906 import 'a.dart' as p; | 1904 import 'a.dart' as p; |
1907 const v = const p.C<int, String>(); | 1905 const v = const p.C<int, String>(); |
1908 '''); | 1906 '''); |
1909 _assertUnlinkedConst(variable.constExpr, operators: [ | 1907 _assertUnlinkedConst(variable.constExpr, operators: [ |
1910 UnlinkedConstOperation.invokeConstructor, | 1908 UnlinkedConstOperation.invokeConstructor, |
1911 ], ints: [ | 1909 ], ints: [ |
1912 0, | 1910 0, |
1913 0 | 1911 0 |
1914 ], referenceValidators: [ | 1912 ], referenceValidators: [ |
1915 (EntityRef r) { | 1913 (EntityRef r) { |
1916 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 1914 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', |
1917 expectedKind: ReferenceKind.classOrEnum, | 1915 expectedKind: ReferenceKind.classOrEnum, |
1918 numTypeParameters: 2, | 1916 numTypeParameters: 2, |
1919 allowTypeParameters: true, | 1917 numTypeArguments: 2, |
1920 prefixExpectations: [ | 1918 prefixExpectations: [ |
1921 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 1919 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
1922 ]); | 1920 ]); |
1923 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1921 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
1924 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1922 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
1925 } | 1923 } |
1926 ]); | 1924 ]); |
1927 } | 1925 } |
1928 | 1926 |
1929 test_constExpr_invokeConstructor_named() { | 1927 test_constExpr_invokeConstructor_named() { |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3730 serializeClassText(text, className: 'C').executables[0]; | 3728 serializeClassText(text, className: 'C').executables[0]; |
3731 expect(executable.isRedirectedConstructor, isTrue); | 3729 expect(executable.isRedirectedConstructor, isTrue); |
3732 expect(executable.isFactory, isTrue); | 3730 expect(executable.isFactory, isTrue); |
3733 expect(executable.redirectedConstructorName, isEmpty); | 3731 expect(executable.redirectedConstructorName, isEmpty); |
3734 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 3732 checkTypeRef(executable.redirectedConstructor, null, null, 'named', |
3735 expectedKind: ReferenceKind.constructor, | 3733 expectedKind: ReferenceKind.constructor, |
3736 prefixExpectations: [ | 3734 prefixExpectations: [ |
3737 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 3735 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', |
3738 numTypeParameters: 2) | 3736 numTypeParameters: 2) |
3739 ], | 3737 ], |
3740 allowTypeParameters: true); | 3738 numTypeArguments: 2); |
3741 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 3739 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
3742 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 3740 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
3743 } | 3741 } |
3744 | 3742 |
3745 test_constructor_redirected_factory_named_imported() { | 3743 test_constructor_redirected_factory_named_imported() { |
3746 addNamedSource( | 3744 addNamedSource( |
3747 '/foo.dart', | 3745 '/foo.dart', |
3748 ''' | 3746 ''' |
3749 import 'test.dart'; | 3747 import 'test.dart'; |
3750 class D extends C { | 3748 class D extends C { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3793 expect(executable.isFactory, isTrue); | 3791 expect(executable.isFactory, isTrue); |
3794 expect(executable.redirectedConstructorName, isEmpty); | 3792 expect(executable.redirectedConstructorName, isEmpty); |
3795 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 3793 checkTypeRef(executable.redirectedConstructor, null, null, 'named', |
3796 expectedKind: ReferenceKind.constructor, | 3794 expectedKind: ReferenceKind.constructor, |
3797 prefixExpectations: [ | 3795 prefixExpectations: [ |
3798 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 3796 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', |
3799 numTypeParameters: 2, | 3797 numTypeParameters: 2, |
3800 absoluteUri: absUri('/foo.dart'), | 3798 absoluteUri: absUri('/foo.dart'), |
3801 relativeUri: 'foo.dart') | 3799 relativeUri: 'foo.dart') |
3802 ], | 3800 ], |
3803 allowTypeParameters: true); | 3801 numTypeArguments: 2); |
3804 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 3802 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
3805 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 3803 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
3806 } | 3804 } |
3807 | 3805 |
3808 test_constructor_redirected_factory_named_prefixed() { | 3806 test_constructor_redirected_factory_named_prefixed() { |
3809 addNamedSource( | 3807 addNamedSource( |
3810 '/foo.dart', | 3808 '/foo.dart', |
3811 ''' | 3809 ''' |
3812 import 'test.dart'; | 3810 import 'test.dart'; |
3813 class D extends C { | 3811 class D extends C { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3858 expect(executable.redirectedConstructorName, isEmpty); | 3856 expect(executable.redirectedConstructorName, isEmpty); |
3859 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 3857 checkTypeRef(executable.redirectedConstructor, null, null, 'named', |
3860 expectedKind: ReferenceKind.constructor, | 3858 expectedKind: ReferenceKind.constructor, |
3861 prefixExpectations: [ | 3859 prefixExpectations: [ |
3862 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 3860 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', |
3863 numTypeParameters: 2, | 3861 numTypeParameters: 2, |
3864 absoluteUri: absUri('/foo.dart'), | 3862 absoluteUri: absUri('/foo.dart'), |
3865 relativeUri: 'foo.dart'), | 3863 relativeUri: 'foo.dart'), |
3866 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 3864 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
3867 ], | 3865 ], |
3868 allowTypeParameters: true); | 3866 numTypeArguments: 2); |
3869 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 3867 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
3870 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 3868 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
3871 } | 3869 } |
3872 | 3870 |
3873 test_constructor_redirected_factory_unnamed() { | 3871 test_constructor_redirected_factory_unnamed() { |
3874 String text = ''' | 3872 String text = ''' |
3875 class C { | 3873 class C { |
3876 factory C() = D; | 3874 factory C() = D; |
3877 C._(); | 3875 C._(); |
3878 } | 3876 } |
(...skipping 18 matching lines...) Expand all Loading... | |
3897 class D<T, U> extends C<U, T> { | 3895 class D<T, U> extends C<U, T> { |
3898 D() : super._(); | 3896 D() : super._(); |
3899 } | 3897 } |
3900 '''; | 3898 '''; |
3901 UnlinkedExecutable executable = | 3899 UnlinkedExecutable executable = |
3902 serializeClassText(text, className: 'C').executables[0]; | 3900 serializeClassText(text, className: 'C').executables[0]; |
3903 expect(executable.isRedirectedConstructor, isTrue); | 3901 expect(executable.isRedirectedConstructor, isTrue); |
3904 expect(executable.isFactory, isTrue); | 3902 expect(executable.isFactory, isTrue); |
3905 expect(executable.redirectedConstructorName, isEmpty); | 3903 expect(executable.redirectedConstructorName, isEmpty); |
3906 checkTypeRef(executable.redirectedConstructor, null, null, 'D', | 3904 checkTypeRef(executable.redirectedConstructor, null, null, 'D', |
3907 allowTypeParameters: true, numTypeParameters: 2); | 3905 numTypeParameters: 2, numTypeArguments: 2); |
3908 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 3906 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
3909 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 3907 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
3910 } | 3908 } |
3911 | 3909 |
3912 test_constructor_redirected_factory_unnamed_imported() { | 3910 test_constructor_redirected_factory_unnamed_imported() { |
3913 addNamedSource( | 3911 addNamedSource( |
3914 '/foo.dart', | 3912 '/foo.dart', |
3915 ''' | 3913 ''' |
3916 import 'test.dart'; | 3914 import 'test.dart'; |
3917 class D extends C { | 3915 class D extends C { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3950 C._(); | 3948 C._(); |
3951 } | 3949 } |
3952 '''; | 3950 '''; |
3953 UnlinkedExecutable executable = | 3951 UnlinkedExecutable executable = |
3954 serializeClassText(text, className: 'C').executables[0]; | 3952 serializeClassText(text, className: 'C').executables[0]; |
3955 expect(executable.isRedirectedConstructor, isTrue); | 3953 expect(executable.isRedirectedConstructor, isTrue); |
3956 expect(executable.isFactory, isTrue); | 3954 expect(executable.isFactory, isTrue); |
3957 expect(executable.redirectedConstructorName, isEmpty); | 3955 expect(executable.redirectedConstructorName, isEmpty); |
3958 checkTypeRef( | 3956 checkTypeRef( |
3959 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', | 3957 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', |
3960 allowTypeParameters: true, numTypeParameters: 2); | 3958 numTypeParameters: 2, numTypeArguments: 2); |
3961 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 3959 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
3962 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 3960 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
3963 } | 3961 } |
3964 | 3962 |
3965 test_constructor_redirected_factory_unnamed_prefixed() { | 3963 test_constructor_redirected_factory_unnamed_prefixed() { |
3966 addNamedSource( | 3964 addNamedSource( |
3967 '/foo.dart', | 3965 '/foo.dart', |
3968 ''' | 3966 ''' |
3969 import 'test.dart'; | 3967 import 'test.dart'; |
3970 class D extends C { | 3968 class D extends C { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4004 C._(); | 4002 C._(); |
4005 } | 4003 } |
4006 '''; | 4004 '''; |
4007 UnlinkedExecutable executable = | 4005 UnlinkedExecutable executable = |
4008 serializeClassText(text, className: 'C').executables[0]; | 4006 serializeClassText(text, className: 'C').executables[0]; |
4009 expect(executable.isRedirectedConstructor, isTrue); | 4007 expect(executable.isRedirectedConstructor, isTrue); |
4010 expect(executable.isFactory, isTrue); | 4008 expect(executable.isFactory, isTrue); |
4011 expect(executable.redirectedConstructorName, isEmpty); | 4009 expect(executable.redirectedConstructorName, isEmpty); |
4012 checkTypeRef( | 4010 checkTypeRef( |
4013 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', | 4011 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', |
4014 allowTypeParameters: true, numTypeParameters: 2, expectedPrefix: 'foo'); | 4012 numTypeParameters: 2, expectedPrefix: 'foo', numTypeArguments: 2); |
4015 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4013 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
4016 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4014 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
4017 } | 4015 } |
4018 | 4016 |
4019 test_constructor_redirected_thisInvocation_named() { | 4017 test_constructor_redirected_thisInvocation_named() { |
4020 String text = ''' | 4018 String text = ''' |
4021 class C { | 4019 class C { |
4022 C() : this.named(); | 4020 C() : this.named(); |
4023 C.named(); | 4021 C.named(); |
4024 } | 4022 } |
(...skipping 4806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8831 expect(propagatedType.syntheticParams, hasLength(2)); | 8829 expect(propagatedType.syntheticParams, hasLength(2)); |
8832 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', | 8830 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', |
8833 'dart:core', 'int'); | 8831 'dart:core', 'int'); |
8834 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', | 8832 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', |
8835 'dart:core', 'String'); | 8833 'dart:core', 'String'); |
8836 } | 8834 } |
8837 | 8835 |
8838 test_type_arguments_explicit() { | 8836 test_type_arguments_explicit() { |
8839 EntityRef typeRef = serializeTypeText('List<int>'); | 8837 EntityRef typeRef = serializeTypeText('List<int>'); |
8840 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 8838 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
8841 allowTypeParameters: true, numTypeParameters: 1); | 8839 numTypeParameters: 1, numTypeArguments: 1); |
8842 expect(typeRef.typeArguments, hasLength(1)); | 8840 expect(typeRef.typeArguments, hasLength(1)); |
8843 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 8841 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
8844 } | 8842 } |
8845 | 8843 |
8846 test_type_arguments_explicit_dynamic() { | 8844 test_type_arguments_explicit_dynamic() { |
8847 EntityRef typeRef = serializeTypeText('List<dynamic>'); | 8845 EntityRef typeRef = serializeTypeText('List<dynamic>'); |
8848 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 8846 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
8849 allowTypeParameters: true, numTypeParameters: 1); | 8847 numTypeParameters: 1); |
8850 expect(typeRef.typeArguments, isEmpty); | 8848 expect(typeRef.typeArguments, isEmpty); |
8851 } | 8849 } |
8852 | 8850 |
8853 test_type_arguments_explicit_dynamic_dynamic() { | 8851 test_type_arguments_explicit_dynamic_dynamic() { |
8854 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); | 8852 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); |
8855 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8853 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
8856 allowTypeParameters: true, numTypeParameters: 2); | 8854 numTypeParameters: 2); |
8857 // Trailing type arguments of type `dynamic` are omitted. | 8855 // Trailing type arguments of type `dynamic` are omitted. |
8858 expect(typeRef.typeArguments, isEmpty); | 8856 expect(typeRef.typeArguments, isEmpty); |
8859 } | 8857 } |
8860 | 8858 |
8861 test_type_arguments_explicit_dynamic_int() { | 8859 test_type_arguments_explicit_dynamic_int() { |
8862 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); | 8860 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); |
8863 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8861 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
8864 allowTypeParameters: true, numTypeParameters: 2); | 8862 numTypeParameters: 2, numTypeArguments: 2); |
8865 // Leading type arguments of type `dynamic` are not omitted. | 8863 // Leading type arguments of type `dynamic` are not omitted. |
8866 expect(typeRef.typeArguments.length, 2); | 8864 expect(typeRef.typeArguments.length, 2); |
8867 checkDynamicTypeRef(typeRef.typeArguments[0]); | 8865 checkDynamicTypeRef(typeRef.typeArguments[0]); |
8868 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8866 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
8869 } | 8867 } |
8870 | 8868 |
8871 test_type_arguments_explicit_dynamic_typedef() { | 8869 test_type_arguments_explicit_dynamic_typedef() { |
8872 EntityRef typeRef = | 8870 EntityRef typeRef = |
8873 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); | 8871 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); |
8874 checkTypeRef(typeRef, null, null, 'F', | 8872 checkTypeRef(typeRef, null, null, 'F', |
8875 allowTypeParameters: true, | |
8876 expectedKind: ReferenceKind.typedef, | 8873 expectedKind: ReferenceKind.typedef, |
8877 numTypeParameters: 1); | 8874 numTypeParameters: 1, |
8875 numTypeArguments: 0); | |
8878 expect(typeRef.typeArguments, isEmpty); | 8876 expect(typeRef.typeArguments, isEmpty); |
8879 } | 8877 } |
8880 | 8878 |
8881 test_type_arguments_explicit_String_dynamic() { | 8879 test_type_arguments_explicit_String_dynamic() { |
8882 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); | 8880 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); |
8883 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8881 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
8884 allowTypeParameters: true, numTypeParameters: 2); | 8882 numTypeParameters: 2, numTypeArguments: 1); |
8885 // Trailing type arguments of type `dynamic` are omitted. | 8883 // Trailing type arguments of type `dynamic` are omitted. |
8886 expect(typeRef.typeArguments.length, 1); | 8884 expect(typeRef.typeArguments.length, 1); |
8887 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 8885 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
8888 } | 8886 } |
8889 | 8887 |
8890 test_type_arguments_explicit_String_int() { | 8888 test_type_arguments_explicit_String_int() { |
8891 EntityRef typeRef = serializeTypeText('Map<String, int>'); | 8889 EntityRef typeRef = serializeTypeText('Map<String, int>'); |
8892 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8890 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
8893 allowTypeParameters: true, numTypeParameters: 2); | 8891 numTypeParameters: 2, numTypeArguments: 2); |
8894 expect(typeRef.typeArguments.length, 2); | 8892 expect(typeRef.typeArguments.length, 2); |
8895 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 8893 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
8896 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8894 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
8897 } | 8895 } |
8898 | 8896 |
8899 test_type_arguments_explicit_typedef() { | 8897 test_type_arguments_explicit_typedef() { |
8900 EntityRef typeRef = | 8898 EntityRef typeRef = |
8901 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); | 8899 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); |
8902 checkTypeRef(typeRef, null, null, 'F', | 8900 checkTypeRef(typeRef, null, null, 'F', |
8903 allowTypeParameters: true, | |
8904 expectedKind: ReferenceKind.typedef, | 8901 expectedKind: ReferenceKind.typedef, |
8905 numTypeParameters: 1); | 8902 numTypeParameters: 1, |
8903 numTypeArguments: 1); | |
8906 expect(typeRef.typeArguments, hasLength(1)); | 8904 expect(typeRef.typeArguments, hasLength(1)); |
8907 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 8905 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
8908 } | 8906 } |
8909 | 8907 |
8910 test_type_arguments_implicit() { | 8908 test_type_arguments_implicit() { |
8911 EntityRef typeRef = serializeTypeText('List'); | 8909 EntityRef typeRef = serializeTypeText('List'); |
8912 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 8910 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
8913 allowTypeParameters: true, numTypeParameters: 1); | 8911 numTypeParameters: 1); |
8914 expect(typeRef.typeArguments, isEmpty); | 8912 expect(typeRef.typeArguments, isEmpty); |
8915 } | 8913 } |
8916 | 8914 |
8917 test_type_arguments_implicit_typedef() { | 8915 test_type_arguments_implicit_typedef() { |
8918 EntityRef typeRef = | 8916 EntityRef typeRef = |
8919 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); | 8917 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); |
8920 checkTypeRef(typeRef, null, null, 'F', | 8918 checkTypeRef(typeRef, null, null, 'F', |
8921 allowTypeParameters: true, | |
8922 expectedKind: ReferenceKind.typedef, | 8919 expectedKind: ReferenceKind.typedef, |
8923 numTypeParameters: 1); | 8920 numTypeParameters: 1, |
8921 numTypeArguments: 0); | |
8924 expect(typeRef.typeArguments, isEmpty); | 8922 expect(typeRef.typeArguments, isEmpty); |
8925 } | 8923 } |
8926 | 8924 |
8927 test_type_arguments_order() { | 8925 test_type_arguments_order() { |
8928 EntityRef typeRef = serializeTypeText('Map<int, Object>'); | 8926 EntityRef typeRef = serializeTypeText('Map<int, Object>'); |
8929 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8927 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
8930 allowTypeParameters: true, numTypeParameters: 2); | 8928 numTypeParameters: 2, numTypeArguments: 2); |
8931 expect(typeRef.typeArguments, hasLength(2)); | 8929 expect(typeRef.typeArguments, hasLength(2)); |
8932 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 8930 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
8933 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); | 8931 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); |
8934 } | 8932 } |
8935 | 8933 |
8936 test_type_dynamic() { | 8934 test_type_dynamic() { |
8937 checkDynamicTypeRef(serializeTypeText('dynamic')); | 8935 checkDynamicTypeRef(serializeTypeText('dynamic')); |
8938 } | 8936 } |
8939 | 8937 |
8940 test_type_param_codeRange() { | 8938 test_type_param_codeRange() { |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9752 class _PrefixExpectation { | 9750 class _PrefixExpectation { |
9753 final ReferenceKind kind; | 9751 final ReferenceKind kind; |
9754 final String name; | 9752 final String name; |
9755 final String absoluteUri; | 9753 final String absoluteUri; |
9756 final String relativeUri; | 9754 final String relativeUri; |
9757 final int numTypeParameters; | 9755 final int numTypeParameters; |
9758 | 9756 |
9759 _PrefixExpectation(this.kind, this.name, | 9757 _PrefixExpectation(this.kind, this.name, |
9760 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9758 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
9761 } | 9759 } |
OLD | NEW |