| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.src.task.dart_test; | 5 library test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/constant.dart'; | 9 import 'package:analyzer/src/generated/constant.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 computeResult(elementA, INFERABLE_STATIC_VARIABLE_DEPENDENCIES, | 1453 computeResult(elementA, INFERABLE_STATIC_VARIABLE_DEPENDENCIES, |
| 1454 matcher: isComputeInferableStaticVariableDependenciesTask); | 1454 matcher: isComputeInferableStaticVariableDependenciesTask); |
| 1455 expect(outputs, hasLength(1)); | 1455 expect(outputs, hasLength(1)); |
| 1456 List<VariableElement> dependencies = | 1456 List<VariableElement> dependencies = |
| 1457 outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; | 1457 outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; |
| 1458 expect(dependencies, unorderedEquals([elementB])); | 1458 expect(dependencies, unorderedEquals([elementB])); |
| 1459 } | 1459 } |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 @reflectiveTest | 1462 @reflectiveTest |
| 1463 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { | |
| 1464 test_perform_definingCompilationUnit() { | |
| 1465 AnalysisTarget library = newSource('/test.dart', 'library test;'); | |
| 1466 computeResult(library, INCLUDED_PARTS); | |
| 1467 computeResult(library, CONTAINING_LIBRARIES, | |
| 1468 matcher: isContainingLibrariesTask); | |
| 1469 expect(outputs, hasLength(1)); | |
| 1470 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | |
| 1471 expect(containingLibraries, unorderedEquals([library])); | |
| 1472 } | |
| 1473 | |
| 1474 test_perform_partInMultipleLibraries() { | |
| 1475 AnalysisTarget library1 = | |
| 1476 newSource('/lib1.dart', 'library test; part "part.dart";'); | |
| 1477 AnalysisTarget library2 = | |
| 1478 newSource('/lib2.dart', 'library test; part "part.dart";'); | |
| 1479 AnalysisTarget part = newSource('/part.dart', 'part of test;'); | |
| 1480 computeResult(library1, INCLUDED_PARTS); | |
| 1481 computeResult(library2, INCLUDED_PARTS); | |
| 1482 computeResult(part, SOURCE_KIND); | |
| 1483 computeResult(part, CONTAINING_LIBRARIES, | |
| 1484 matcher: isContainingLibrariesTask); | |
| 1485 expect(outputs, hasLength(1)); | |
| 1486 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | |
| 1487 expect(containingLibraries, unorderedEquals([library1, library2])); | |
| 1488 } | |
| 1489 | |
| 1490 test_perform_partInSingleLibrary() { | |
| 1491 AnalysisTarget library = | |
| 1492 newSource('/lib.dart', 'library test; part "part.dart";'); | |
| 1493 AnalysisTarget part = newSource('/part.dart', 'part of test;'); | |
| 1494 computeResult(library, INCLUDED_PARTS); | |
| 1495 computeResult(part, SOURCE_KIND); | |
| 1496 computeResult(part, CONTAINING_LIBRARIES, | |
| 1497 matcher: isContainingLibrariesTask); | |
| 1498 expect(outputs, hasLength(1)); | |
| 1499 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | |
| 1500 expect(containingLibraries, unorderedEquals([library])); | |
| 1501 } | |
| 1502 } | |
| 1503 | |
| 1504 @reflectiveTest | |
| 1505 class ComputeLibraryCycleTaskTest extends _AbstractDartTaskTest { | 1463 class ComputeLibraryCycleTaskTest extends _AbstractDartTaskTest { |
| 1506 @override | 1464 @override |
| 1507 void setUp() { | 1465 void setUp() { |
| 1508 super.setUp(); | 1466 super.setUp(); |
| 1509 enableStrongMode(); | 1467 enableStrongMode(); |
| 1510 } | 1468 } |
| 1511 | 1469 |
| 1512 void test_library_cycle_singleton() { | |
| 1513 Source source = newSource( | |
| 1514 '/test.dart', | |
| 1515 ''' | |
| 1516 import 'dart:core'; | |
| 1517 '''); | |
| 1518 computeResult(new LibrarySpecificUnit(source, source), LIBRARY_CYCLE); | |
| 1519 List<LibraryElement> component = outputs[LIBRARY_CYCLE]; | |
| 1520 List<CompilationUnitElement> units = outputs[LIBRARY_CYCLE_UNITS]; | |
| 1521 List<CompilationUnitElement> deps = outputs[LIBRARY_CYCLE_DEPENDENCIES]; | |
| 1522 expect(component, hasLength(1)); | |
| 1523 expect(units, hasLength(1)); | |
| 1524 expect(deps, hasLength(1)); | |
| 1525 } | |
| 1526 | |
| 1527 void test_library_cycle_linear() { | 1470 void test_library_cycle_linear() { |
| 1528 List<Source> sources = newSources({ | 1471 List<Source> sources = newSources({ |
| 1529 '/a.dart': ''' | 1472 '/a.dart': ''' |
| 1530 ''', | 1473 ''', |
| 1531 '/b.dart': ''' | 1474 '/b.dart': ''' |
| 1532 import 'a.dart'; | 1475 import 'a.dart'; |
| 1533 ''' | 1476 ''' |
| 1534 }); | 1477 }); |
| 1535 List<Map<ResultDescriptor, dynamic>> results = | 1478 List<Map<ResultDescriptor, dynamic>> results = |
| 1536 computeLibraryResultsMap(sources, LIBRARY_CYCLE); | 1479 computeLibraryResultsMap(sources, LIBRARY_CYCLE); |
| 1537 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; | 1480 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; |
| 1538 List<LibraryElement> component1 = results[1][LIBRARY_CYCLE]; | 1481 List<LibraryElement> component1 = results[1][LIBRARY_CYCLE]; |
| 1539 expect(component0, hasLength(1)); | 1482 expect(component0, hasLength(1)); |
| 1540 expect(component1, hasLength(1)); | 1483 expect(component1, hasLength(1)); |
| 1541 | 1484 |
| 1542 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; | 1485 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; |
| 1543 List<CompilationUnitElement> units1 = results[1][LIBRARY_CYCLE_UNITS]; | 1486 List<CompilationUnitElement> units1 = results[1][LIBRARY_CYCLE_UNITS]; |
| 1544 expect(units0, hasLength(1)); | 1487 expect(units0, hasLength(1)); |
| 1545 expect(units1, hasLength(1)); | 1488 expect(units1, hasLength(1)); |
| 1546 | 1489 |
| 1547 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; | 1490 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1548 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; | 1491 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1549 expect(dep0, hasLength(1)); // dart:core | 1492 expect(dep0, hasLength(1)); // dart:core |
| 1550 expect(dep1, hasLength(2)); // dart:core, a.dart | 1493 expect(dep1, hasLength(2)); // dart:core, a.dart |
| 1551 } | 1494 } |
| 1552 | 1495 |
| 1553 void test_library_cycle_tree() { | |
| 1554 List<Source> sources = newSources({ | |
| 1555 '/a.dart': ''' | |
| 1556 ''', | |
| 1557 '/b.dart': ''' | |
| 1558 ''', | |
| 1559 '/c.dart': ''' | |
| 1560 import 'a.dart'; | |
| 1561 import 'b.dart'; | |
| 1562 ''' | |
| 1563 }); | |
| 1564 List<Map<ResultDescriptor, dynamic>> results = | |
| 1565 computeLibraryResultsMap(sources, LIBRARY_CYCLE); | |
| 1566 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; | |
| 1567 List<LibraryElement> component1 = results[1][LIBRARY_CYCLE]; | |
| 1568 List<LibraryElement> component2 = results[2][LIBRARY_CYCLE]; | |
| 1569 expect(component0, hasLength(1)); | |
| 1570 expect(component1, hasLength(1)); | |
| 1571 expect(component2, hasLength(1)); | |
| 1572 | |
| 1573 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; | |
| 1574 List<CompilationUnitElement> units1 = results[1][LIBRARY_CYCLE_UNITS]; | |
| 1575 List<CompilationUnitElement> units2 = results[2][LIBRARY_CYCLE_UNITS]; | |
| 1576 expect(units0, hasLength(1)); | |
| 1577 expect(units1, hasLength(1)); | |
| 1578 expect(units2, hasLength(1)); | |
| 1579 | |
| 1580 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; | |
| 1581 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; | |
| 1582 List<CompilationUnitElement> dep2 = results[2][LIBRARY_CYCLE_DEPENDENCIES]; | |
| 1583 expect(dep0, hasLength(1)); // dart:core | |
| 1584 expect(dep1, hasLength(1)); // dart:core, | |
| 1585 expect(dep2, hasLength(3)); // dart:core, a.dart, b.dart | |
| 1586 } | |
| 1587 | |
| 1588 void test_library_cycle_loop() { | 1496 void test_library_cycle_loop() { |
| 1589 List<Source> sources = newSources({ | 1497 List<Source> sources = newSources({ |
| 1590 '/a.dart': ''' | 1498 '/a.dart': ''' |
| 1591 import 'c.dart'; | 1499 import 'c.dart'; |
| 1592 ''', | 1500 ''', |
| 1593 '/b.dart': ''' | 1501 '/b.dart': ''' |
| 1594 import 'a.dart'; | 1502 import 'a.dart'; |
| 1595 ''', | 1503 ''', |
| 1596 '/c.dart': ''' | 1504 '/c.dart': ''' |
| 1597 import 'b.dart'; | 1505 import 'b.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; | 1541 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; |
| 1634 expect(component0, hasLength(1)); | 1542 expect(component0, hasLength(1)); |
| 1635 | 1543 |
| 1636 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; | 1544 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; |
| 1637 expect(units0, hasLength(1)); | 1545 expect(units0, hasLength(1)); |
| 1638 | 1546 |
| 1639 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; | 1547 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1640 expect(dep0, hasLength(1)); // dart:core | 1548 expect(dep0, hasLength(1)); // dart:core |
| 1641 } | 1549 } |
| 1642 | 1550 |
| 1551 void test_library_cycle_singleton() { |
| 1552 Source source = newSource( |
| 1553 '/test.dart', |
| 1554 ''' |
| 1555 import 'dart:core'; |
| 1556 '''); |
| 1557 computeResult(new LibrarySpecificUnit(source, source), LIBRARY_CYCLE); |
| 1558 List<LibraryElement> component = outputs[LIBRARY_CYCLE]; |
| 1559 List<CompilationUnitElement> units = outputs[LIBRARY_CYCLE_UNITS]; |
| 1560 List<CompilationUnitElement> deps = outputs[LIBRARY_CYCLE_DEPENDENCIES]; |
| 1561 expect(component, hasLength(1)); |
| 1562 expect(units, hasLength(1)); |
| 1563 expect(deps, hasLength(1)); |
| 1564 } |
| 1565 |
| 1566 void test_library_cycle_tree() { |
| 1567 List<Source> sources = newSources({ |
| 1568 '/a.dart': ''' |
| 1569 ''', |
| 1570 '/b.dart': ''' |
| 1571 ''', |
| 1572 '/c.dart': ''' |
| 1573 import 'a.dart'; |
| 1574 import 'b.dart'; |
| 1575 ''' |
| 1576 }); |
| 1577 List<Map<ResultDescriptor, dynamic>> results = |
| 1578 computeLibraryResultsMap(sources, LIBRARY_CYCLE); |
| 1579 List<LibraryElement> component0 = results[0][LIBRARY_CYCLE]; |
| 1580 List<LibraryElement> component1 = results[1][LIBRARY_CYCLE]; |
| 1581 List<LibraryElement> component2 = results[2][LIBRARY_CYCLE]; |
| 1582 expect(component0, hasLength(1)); |
| 1583 expect(component1, hasLength(1)); |
| 1584 expect(component2, hasLength(1)); |
| 1585 |
| 1586 List<CompilationUnitElement> units0 = results[0][LIBRARY_CYCLE_UNITS]; |
| 1587 List<CompilationUnitElement> units1 = results[1][LIBRARY_CYCLE_UNITS]; |
| 1588 List<CompilationUnitElement> units2 = results[2][LIBRARY_CYCLE_UNITS]; |
| 1589 expect(units0, hasLength(1)); |
| 1590 expect(units1, hasLength(1)); |
| 1591 expect(units2, hasLength(1)); |
| 1592 |
| 1593 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1594 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1595 List<CompilationUnitElement> dep2 = results[2][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1596 expect(dep0, hasLength(1)); // dart:core |
| 1597 expect(dep1, hasLength(1)); // dart:core, |
| 1598 expect(dep2, hasLength(3)); // dart:core, a.dart, b.dart |
| 1599 } |
| 1600 |
| 1643 void test_library_double_loop() { | 1601 void test_library_double_loop() { |
| 1644 List<Source> sources = newSources({ | 1602 List<Source> sources = newSources({ |
| 1645 '/a.dart': ''' | 1603 '/a.dart': ''' |
| 1646 import 'b.dart'; | 1604 import 'b.dart'; |
| 1647 ''', | 1605 ''', |
| 1648 '/b.dart': ''' | 1606 '/b.dart': ''' |
| 1649 import 'a.dart'; | 1607 import 'a.dart'; |
| 1650 ''', | 1608 ''', |
| 1651 '/c.dart': ''' | 1609 '/c.dart': ''' |
| 1652 import 'd.dart' as foo; | 1610 import 'd.dart' as foo; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 expect(dep2, hasLength(1)); // dart:core | 1752 expect(dep2, hasLength(1)); // dart:core |
| 1795 expect(dep3, hasLength(1)); // dart:core | 1753 expect(dep3, hasLength(1)); // dart:core |
| 1796 expect(dep4, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart | 1754 expect(dep4, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart |
| 1797 expect(dep5, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart | 1755 expect(dep5, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart |
| 1798 expect(dep6, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart | 1756 expect(dep6, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart |
| 1799 expect(dep7, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart | 1757 expect(dep7, hasLength(5)); // dart:core, a.dart, aa.dart, ab.dart, b.dart |
| 1800 } | 1758 } |
| 1801 } | 1759 } |
| 1802 | 1760 |
| 1803 @reflectiveTest | 1761 @reflectiveTest |
| 1762 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { |
| 1763 test_perform_definingCompilationUnit() { |
| 1764 AnalysisTarget library = newSource('/test.dart', 'library test;'); |
| 1765 computeResult(library, INCLUDED_PARTS); |
| 1766 computeResult(library, CONTAINING_LIBRARIES, |
| 1767 matcher: isContainingLibrariesTask); |
| 1768 expect(outputs, hasLength(1)); |
| 1769 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
| 1770 expect(containingLibraries, unorderedEquals([library])); |
| 1771 } |
| 1772 |
| 1773 test_perform_partInMultipleLibraries() { |
| 1774 AnalysisTarget library1 = |
| 1775 newSource('/lib1.dart', 'library test; part "part.dart";'); |
| 1776 AnalysisTarget library2 = |
| 1777 newSource('/lib2.dart', 'library test; part "part.dart";'); |
| 1778 AnalysisTarget part = newSource('/part.dart', 'part of test;'); |
| 1779 computeResult(library1, INCLUDED_PARTS); |
| 1780 computeResult(library2, INCLUDED_PARTS); |
| 1781 computeResult(part, SOURCE_KIND); |
| 1782 computeResult(part, CONTAINING_LIBRARIES, |
| 1783 matcher: isContainingLibrariesTask); |
| 1784 expect(outputs, hasLength(1)); |
| 1785 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
| 1786 expect(containingLibraries, unorderedEquals([library1, library2])); |
| 1787 } |
| 1788 |
| 1789 test_perform_partInSingleLibrary() { |
| 1790 AnalysisTarget library = |
| 1791 newSource('/lib.dart', 'library test; part "part.dart";'); |
| 1792 AnalysisTarget part = newSource('/part.dart', 'part of test;'); |
| 1793 computeResult(library, INCLUDED_PARTS); |
| 1794 computeResult(part, SOURCE_KIND); |
| 1795 computeResult(part, CONTAINING_LIBRARIES, |
| 1796 matcher: isContainingLibrariesTask); |
| 1797 expect(outputs, hasLength(1)); |
| 1798 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
| 1799 expect(containingLibraries, unorderedEquals([library])); |
| 1800 } |
| 1801 } |
| 1802 |
| 1803 @reflectiveTest |
| 1804 class DartErrorsTaskTest extends _AbstractDartTaskTest { | 1804 class DartErrorsTaskTest extends _AbstractDartTaskTest { |
| 1805 test_perform_definingCompilationUnit() { | 1805 test_perform_definingCompilationUnit() { |
| 1806 AnalysisTarget library = | 1806 AnalysisTarget library = |
| 1807 newSource('/test.dart', 'library test; import "dart:math";'); | 1807 newSource('/test.dart', 'library test; import "dart:math";'); |
| 1808 computeResult(library, INCLUDED_PARTS); | 1808 computeResult(library, INCLUDED_PARTS); |
| 1809 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask); | 1809 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask); |
| 1810 expect(outputs, hasLength(1)); | 1810 expect(outputs, hasLength(1)); |
| 1811 List<AnalysisError> errors = outputs[DART_ERRORS]; | 1811 List<AnalysisError> errors = outputs[DART_ERRORS]; |
| 1812 expect(errors, hasLength(1)); | 1812 expect(errors, hasLength(1)); |
| 1813 } | 1813 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 usedElements = outputs[USED_IMPORTED_ELEMENTS]; | 1900 usedElements = outputs[USED_IMPORTED_ELEMENTS]; |
| 1901 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); | 1901 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); |
| 1902 } | 1902 } |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 @reflectiveTest | 1905 @reflectiveTest |
| 1906 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest { | 1906 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest { |
| 1907 UsedLocalElements usedElements; | 1907 UsedLocalElements usedElements; |
| 1908 Set<String> usedElementNames; | 1908 Set<String> usedElementNames; |
| 1909 | 1909 |
| 1910 fail_perform_forPart_afterLibraryUpdate() { |
| 1911 Source libSource = newSource( |
| 1912 '/my_lib.dart', |
| 1913 ''' |
| 1914 library my_lib; |
| 1915 part 'my_part.dart'; |
| 1916 foo() => null; |
| 1917 class _LocalClass {} |
| 1918 '''); |
| 1919 Source partSource = newSource( |
| 1920 '/my_part.dart', |
| 1921 ''' |
| 1922 part of my_lib; |
| 1923 bar() { |
| 1924 print(_LocalClass); |
| 1925 } |
| 1926 '''); |
| 1927 AnalysisTarget libTarget = new LibrarySpecificUnit(libSource, libSource); |
| 1928 AnalysisTarget partTarget = new LibrarySpecificUnit(libSource, partSource); |
| 1929 computeResult(libTarget, USED_LOCAL_ELEMENTS); |
| 1930 computeResult(partTarget, USED_LOCAL_ELEMENTS); |
| 1931 // _LocalClass is used in my_part.dart |
| 1932 { |
| 1933 UsedLocalElements usedElements = |
| 1934 analysisCache.getValue(partTarget, USED_LOCAL_ELEMENTS); |
| 1935 expect(usedElements.elements, contains(predicate((Element e) { |
| 1936 return e.displayName == '_LocalClass'; |
| 1937 }))); |
| 1938 } |
| 1939 // change my_lib.dart and recompute |
| 1940 context.setContents( |
| 1941 libSource, |
| 1942 ''' |
| 1943 library my_lib; |
| 1944 part 'my_part.dart'; |
| 1945 String foo() => null; |
| 1946 class _LocalClass {} |
| 1947 '''); |
| 1948 computeResult(libTarget, USED_LOCAL_ELEMENTS); |
| 1949 computeResult(partTarget, USED_LOCAL_ELEMENTS); |
| 1950 // _LocalClass should still be used in my_part.dart |
| 1951 { |
| 1952 UsedLocalElements usedElements = |
| 1953 analysisCache.getValue(partTarget, USED_LOCAL_ELEMENTS); |
| 1954 expect(usedElements.elements, contains(predicate((Element e) { |
| 1955 return e.displayName == '_LocalClass'; |
| 1956 }))); |
| 1957 } |
| 1958 } |
| 1959 |
| 1910 test_perform_localVariable() { | 1960 test_perform_localVariable() { |
| 1911 Source source = newSource( | 1961 Source source = newSource( |
| 1912 '/test.dart', | 1962 '/test.dart', |
| 1913 r''' | 1963 r''' |
| 1914 main() { | 1964 main() { |
| 1915 var v1 = 1; | 1965 var v1 = 1; |
| 1916 var v2 = 2; | 1966 var v2 = 2; |
| 1917 print(v2); | 1967 print(v2); |
| 1918 }'''); | 1968 }'''); |
| 1919 _computeUsedElements(source); | 1969 _computeUsedElements(source); |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2899 | 2949 |
| 2900 @reflectiveTest | 2950 @reflectiveTest |
| 2901 class ResolveInstanceFieldsInUnitTaskTest extends _AbstractDartTaskTest { | 2951 class ResolveInstanceFieldsInUnitTaskTest extends _AbstractDartTaskTest { |
| 2902 @override | 2952 @override |
| 2903 void setUp() { | 2953 void setUp() { |
| 2904 super.setUp(); | 2954 super.setUp(); |
| 2905 enableStrongMode(); | 2955 enableStrongMode(); |
| 2906 } | 2956 } |
| 2907 | 2957 |
| 2908 // Test inference of instance fields across units | 2958 // Test inference of instance fields across units |
| 2909 void test_perform_inference_instance() { | |
| 2910 List<Source> sources = newSources({ | |
| 2911 '/a.dart': ''' | |
| 2912 import 'b.dart'; | |
| 2913 class A { | |
| 2914 final a2 = new B().b2; | |
| 2915 } | |
| 2916 | |
| 2917 class B { | |
| 2918 final b2 = 1; | |
| 2919 } | |
| 2920 ''', | |
| 2921 '/main.dart': ''' | |
| 2922 import "a.dart"; | |
| 2923 | |
| 2924 test1() { | |
| 2925 int x = 0; | |
| 2926 x = new A().a2; | |
| 2927 } | |
| 2928 ''' | |
| 2929 }); | |
| 2930 InterfaceType intType = context.typeProvider.intType; | |
| 2931 DartType dynamicType = context.typeProvider.dynamicType; | |
| 2932 | |
| 2933 computeResult( | |
| 2934 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT7); | |
| 2935 CompilationUnit unit0 = outputs[RESOLVED_UNIT7]; | |
| 2936 | |
| 2937 // A.a2 should now be resolved on the rhs, but not yet inferred. | |
| 2938 assertVariableDeclarationTypes( | |
| 2939 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | |
| 2940 | |
| 2941 // B.b2 shoud be resolved on the rhs, but not yet inferred. | |
| 2942 assertVariableDeclarationTypes( | |
| 2943 getFieldInClass(unit0, "B", "b2"), dynamicType, intType); | |
| 2944 | |
| 2945 computeResult( | |
| 2946 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT7); | |
| 2947 CompilationUnit unit1 = outputs[RESOLVED_UNIT7]; | |
| 2948 | |
| 2949 // A.a2 should now be fully resolved and inferred. | |
| 2950 assertVariableDeclarationTypes( | |
| 2951 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | |
| 2952 | |
| 2953 // B.b2 should now be fully resolved and inferred. | |
| 2954 assertVariableDeclarationTypes( | |
| 2955 getFieldInClass(unit0, "B", "b2"), intType, intType); | |
| 2956 } | |
| 2957 | |
| 2958 // Test inference of instance fields across units | |
| 2959 void test_perform_inference_cross_unit_instance() { | 2959 void test_perform_inference_cross_unit_instance() { |
| 2960 List<Source> sources = newSources({ | 2960 List<Source> sources = newSources({ |
| 2961 '/a.dart': ''' | 2961 '/a.dart': ''' |
| 2962 import 'b.dart'; | 2962 import 'b.dart'; |
| 2963 class A { | 2963 class A { |
| 2964 final a2 = new B().b2; | 2964 final a2 = new B().b2; |
| 2965 } | 2965 } |
| 2966 ''', | 2966 ''', |
| 2967 '/b.dart': ''' | 2967 '/b.dart': ''' |
| 2968 class B { | 2968 class B { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; | 3006 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; |
| 3007 | 3007 |
| 3008 // A.a2 should now be fully resolved and inferred. | 3008 // A.a2 should now be fully resolved and inferred. |
| 3009 assertVariableDeclarationTypes( | 3009 assertVariableDeclarationTypes( |
| 3010 getFieldInClass(unit0, "A", "a2"), intType, intType); | 3010 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3011 | 3011 |
| 3012 assertVariableDeclarationTypes( | 3012 assertVariableDeclarationTypes( |
| 3013 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3013 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3014 } | 3014 } |
| 3015 | 3015 |
| 3016 // Test inference of instance fields across units with cycles | 3016 // Test inference of instance fields across units |
| 3017 void test_perform_inference_cross_unit_instance_cyclic() { | 3017 void test_perform_inference_cross_unit_instance_cyclic() { |
| 3018 List<Source> sources = newSources({ | 3018 List<Source> sources = newSources({ |
| 3019 '/a.dart': ''' | 3019 '/a.dart': ''' |
| 3020 import 'b.dart'; | 3020 import 'b.dart'; |
| 3021 class A { | 3021 class A { |
| 3022 final a2 = new B().b2; | 3022 final a2 = new B().b2; |
| 3023 } | 3023 } |
| 3024 ''', | 3024 ''', |
| 3025 '/b.dart': ''' | 3025 '/b.dart': ''' |
| 3026 import 'a.dart'; | 3026 import 'a.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3050 | 3050 |
| 3051 computeResult( | 3051 computeResult( |
| 3052 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); | 3052 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); |
| 3053 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; | 3053 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; |
| 3054 | 3054 |
| 3055 // A.a2 should now be fully resolved and inferred. | 3055 // A.a2 should now be fully resolved and inferred. |
| 3056 assertVariableDeclarationTypes( | 3056 assertVariableDeclarationTypes( |
| 3057 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3057 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3058 } | 3058 } |
| 3059 | 3059 |
| 3060 // Test inference between static and instance fields | 3060 // Test inference of instance fields across units with cycles |
| 3061 void test_perform_inference_cross_unit_static_instance() { | 3061 void test_perform_inference_cross_unit_static_instance() { |
| 3062 List<Source> sources = newSources({ | 3062 List<Source> sources = newSources({ |
| 3063 '/a.dart': ''' | 3063 '/a.dart': ''' |
| 3064 import 'b.dart'; | 3064 import 'b.dart'; |
| 3065 class A { | 3065 class A { |
| 3066 static final a1 = B.b1; | 3066 static final a1 = B.b1; |
| 3067 final a2 = new B().b2; | 3067 final a2 = new B().b2; |
| 3068 } | 3068 } |
| 3069 ''', | 3069 ''', |
| 3070 '/b.dart': ''' | 3070 '/b.dart': ''' |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3117 assertVariableDeclarationTypes( | 3117 assertVariableDeclarationTypes( |
| 3118 getFieldInClass(unit0, "A", "a1"), intType, intType); | 3118 getFieldInClass(unit0, "A", "a1"), intType, intType); |
| 3119 assertVariableDeclarationTypes( | 3119 assertVariableDeclarationTypes( |
| 3120 getFieldInClass(unit0, "A", "a2"), intType, intType); | 3120 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3121 | 3121 |
| 3122 assertVariableDeclarationTypes( | 3122 assertVariableDeclarationTypes( |
| 3123 getFieldInClass(unit1, "B", "b1"), intType, intType); | 3123 getFieldInClass(unit1, "B", "b1"), intType, intType); |
| 3124 assertVariableDeclarationTypes( | 3124 assertVariableDeclarationTypes( |
| 3125 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3125 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3126 } | 3126 } |
| 3127 |
| 3128 // Test inference between static and instance fields |
| 3129 void test_perform_inference_instance() { |
| 3130 List<Source> sources = newSources({ |
| 3131 '/a.dart': ''' |
| 3132 import 'b.dart'; |
| 3133 class A { |
| 3134 final a2 = new B().b2; |
| 3135 } |
| 3136 |
| 3137 class B { |
| 3138 final b2 = 1; |
| 3139 } |
| 3140 ''', |
| 3141 '/main.dart': ''' |
| 3142 import "a.dart"; |
| 3143 |
| 3144 test1() { |
| 3145 int x = 0; |
| 3146 x = new A().a2; |
| 3147 } |
| 3148 ''' |
| 3149 }); |
| 3150 InterfaceType intType = context.typeProvider.intType; |
| 3151 DartType dynamicType = context.typeProvider.dynamicType; |
| 3152 |
| 3153 computeResult( |
| 3154 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT7); |
| 3155 CompilationUnit unit0 = outputs[RESOLVED_UNIT7]; |
| 3156 |
| 3157 // A.a2 should now be resolved on the rhs, but not yet inferred. |
| 3158 assertVariableDeclarationTypes( |
| 3159 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3160 |
| 3161 // B.b2 shoud be resolved on the rhs, but not yet inferred. |
| 3162 assertVariableDeclarationTypes( |
| 3163 getFieldInClass(unit0, "B", "b2"), dynamicType, intType); |
| 3164 |
| 3165 computeResult( |
| 3166 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT7); |
| 3167 CompilationUnit unit1 = outputs[RESOLVED_UNIT7]; |
| 3168 |
| 3169 // A.a2 should now be fully resolved and inferred. |
| 3170 assertVariableDeclarationTypes( |
| 3171 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3172 |
| 3173 // B.b2 should now be fully resolved and inferred. |
| 3174 assertVariableDeclarationTypes( |
| 3175 getFieldInClass(unit0, "B", "b2"), intType, intType); |
| 3176 } |
| 3127 } | 3177 } |
| 3128 | 3178 |
| 3129 @reflectiveTest | 3179 @reflectiveTest |
| 3130 class ResolveLibraryTypeNamesTaskTest extends _AbstractDartTaskTest { | 3180 class ResolveLibraryTypeNamesTaskTest extends _AbstractDartTaskTest { |
| 3131 test_perform() { | 3181 test_perform() { |
| 3132 Source sourceLib = newSource( | 3182 Source sourceLib = newSource( |
| 3133 '/my_lib.dart', | 3183 '/my_lib.dart', |
| 3134 ''' | 3184 ''' |
| 3135 library my_lib; | 3185 library my_lib; |
| 3136 part 'my_part.dart'; | 3186 part 'my_part.dart'; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3466 VariableElement tau = getTopLevelVariable(unit, 'tau').name.staticElement; | 3516 VariableElement tau = getTopLevelVariable(unit, 'tau').name.staticElement; |
| 3467 Expression piFirstUse = (getTopLevelVariable(unit, 'tau').initializer | 3517 Expression piFirstUse = (getTopLevelVariable(unit, 'tau').initializer |
| 3468 as ConditionalExpression).condition; | 3518 as ConditionalExpression).condition; |
| 3469 | 3519 |
| 3470 expect(piFirstUse.staticType, context.typeProvider.boolType); | 3520 expect(piFirstUse.staticType, context.typeProvider.boolType); |
| 3471 expect(piFirst.type, context.typeProvider.boolType); | 3521 expect(piFirst.type, context.typeProvider.boolType); |
| 3472 expect(pi.type.isDynamic, isTrue); | 3522 expect(pi.type.isDynamic, isTrue); |
| 3473 expect(tau.type.isDynamic, isTrue); | 3523 expect(tau.type.isDynamic, isTrue); |
| 3474 } | 3524 } |
| 3475 | 3525 |
| 3476 void test_perform_local_explicit_disabled() { | 3526 void test_perform_inference_cross_unit_cyclic() { |
| 3477 AnalysisTarget source = newSource( | 3527 AnalysisTarget firstSource = newSource( |
| 3478 '/test.dart', | 3528 '/a.dart', |
| 3479 ''' | 3529 ''' |
| 3480 test() { | 3530 import 'test.dart'; |
| 3481 int x = 3; | 3531 var x = 2; |
| 3482 x = "hi"; | 3532 class A { static var x = 2; } |
| 3483 } | 3533 '''); |
| 3484 '''); | 3534 AnalysisTarget secondSource = newSource( |
| 3485 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9); | 3535 '/test.dart', |
| 3486 CompilationUnit unit = outputs[RESOLVED_UNIT9]; | 3536 ''' |
| 3537 import 'a.dart'; |
| 3538 var y = x; |
| 3539 class B { static var y = A.x; } |
| 3540 |
| 3541 test1() { |
| 3542 int t = 3; |
| 3543 t = x; |
| 3544 t = y; |
| 3545 t = A.x; |
| 3546 t = B.y; |
| 3547 } |
| 3548 '''); |
| 3549 computeResult( |
| 3550 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9); |
| 3551 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; |
| 3552 computeResult( |
| 3553 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9); |
| 3554 CompilationUnit unit2 = outputs[RESOLVED_UNIT9]; |
| 3555 |
| 3556 InterfaceType intType = context.typeProvider.intType; |
| 3557 |
| 3558 assertVariableDeclarationTypes( |
| 3559 getTopLevelVariable(unit1, "x"), intType, intType); |
| 3560 assertVariableDeclarationTypes( |
| 3561 getFieldInClass(unit1, "A", "x"), intType, intType); |
| 3562 |
| 3563 assertVariableDeclarationTypes( |
| 3564 getTopLevelVariable(unit2, "y"), intType, intType); |
| 3565 assertVariableDeclarationTypes( |
| 3566 getFieldInClass(unit2, "B", "y"), intType, intType); |
| 3567 |
| 3568 List<Statement> statements = |
| 3569 getStatementsInTopLevelFunction(unit2, "test1"); |
| 3570 |
| 3571 assertAssignmentStatementTypes(statements[1], intType, intType); |
| 3572 assertAssignmentStatementTypes(statements[2], intType, intType); |
| 3573 assertAssignmentStatementTypes(statements[3], intType, intType); |
| 3574 assertAssignmentStatementTypes(statements[4], intType, intType); |
| 3575 } |
| 3576 |
| 3577 // Test that local variables in method bodies are inferred appropriately |
| 3578 void test_perform_inference_cross_unit_instance() { |
| 3579 List<Source> sources = newSources({ |
| 3580 '/a.dart': ''' |
| 3581 import 'b.dart'; |
| 3582 class A { |
| 3583 final a2 = new B().b2; |
| 3584 } |
| 3585 ''', |
| 3586 '/b.dart': ''' |
| 3587 class B { |
| 3588 final b2 = 1; |
| 3589 } |
| 3590 ''', |
| 3591 '/main.dart': ''' |
| 3592 import "a.dart"; |
| 3593 |
| 3594 test1() { |
| 3595 int x = 0; |
| 3596 x = new A().a2; |
| 3597 } |
| 3598 ''' |
| 3599 }); |
| 3600 List<dynamic> units = |
| 3601 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); |
| 3602 CompilationUnit unit0 = units[0]; |
| 3603 CompilationUnit unit1 = units[1]; |
| 3604 CompilationUnit unit2 = units[2]; |
| 3605 |
| 3606 InterfaceType intType = context.typeProvider.intType; |
| 3607 |
| 3608 assertVariableDeclarationTypes( |
| 3609 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3610 |
| 3611 assertVariableDeclarationTypes( |
| 3612 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3613 |
| 3614 List<Statement> statements = |
| 3615 getStatementsInTopLevelFunction(unit2, "test1"); |
| 3616 |
| 3617 assertAssignmentStatementTypes(statements[1], intType, intType); |
| 3618 } |
| 3619 |
| 3620 // Test inference interactions between local variables and fields |
| 3621 void test_perform_inference_cross_unit_instance_member() { |
| 3622 List<Source> sources = newSources({ |
| 3623 '/a.dart': ''' |
| 3624 import 'b.dart'; |
| 3625 var bar = new B(); |
| 3626 void foo() { |
| 3627 String x = bar.f.z; |
| 3628 } |
| 3629 ''', |
| 3630 '/b.dart': ''' |
| 3631 class C { |
| 3632 var z = 3; |
| 3633 } |
| 3634 |
| 3635 class B { |
| 3636 var f = new C(); |
| 3637 } |
| 3638 ''', |
| 3639 '/c.dart': ''' |
| 3640 import 'b.dart'; |
| 3641 var bar = new B(); |
| 3642 void foo() { |
| 3643 String x = bar.f.z; |
| 3644 } |
| 3645 ''' |
| 3646 }); |
| 3647 List<dynamic> units = |
| 3648 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); |
| 3649 CompilationUnit unit0 = units[0]; |
| 3650 CompilationUnit unit1 = units[1]; |
| 3651 CompilationUnit unit2 = units[2]; |
| 3487 | 3652 |
| 3488 InterfaceType intType = context.typeProvider.intType; | 3653 InterfaceType intType = context.typeProvider.intType; |
| 3489 InterfaceType stringType = context.typeProvider.stringType; | 3654 InterfaceType stringType = context.typeProvider.stringType; |
| 3490 | 3655 |
| 3491 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); | 3656 assertVariableDeclarationStatementTypes( |
| 3492 VariableDeclaration decl = | 3657 getStatementsInTopLevelFunction(unit0, "foo")[0], stringType, intType); |
| 3493 (statements[0] as VariableDeclarationStatement).variables.variables[0]; | 3658 assertVariableDeclarationStatementTypes( |
| 3494 expect(decl.element.type, intType); | 3659 getStatementsInTopLevelFunction(unit2, "foo")[0], stringType, intType); |
| 3495 expect(decl.initializer.staticType, intType); | 3660 } |
| 3496 | 3661 |
| 3497 ExpressionStatement statement = statements[1]; | 3662 // Test inference interactions between local variables and top level |
| 3498 AssignmentExpression assgn = statement.expression; | 3663 // variables |
| 3499 expect(assgn.leftHandSide.staticType, intType); | 3664 void test_perform_inference_cross_unit_non_cyclic() { |
| 3500 expect(assgn.rightHandSide.staticType, stringType); | 3665 AnalysisTarget firstSource = newSource( |
| 3501 } | 3666 '/a.dart', |
| 3502 | 3667 ''' |
| 3503 // Test that local variables in method bodies are inferred appropriately | 3668 var x = 2; |
| 3669 class A { static var x = 2; } |
| 3670 '''); |
| 3671 AnalysisTarget secondSource = newSource( |
| 3672 '/test.dart', |
| 3673 ''' |
| 3674 import 'a.dart'; |
| 3675 var y = x; |
| 3676 class B { static var y = A.x; } |
| 3677 |
| 3678 test1() { |
| 3679 x = /*severe:StaticTypeError*/"hi"; |
| 3680 y = /*severe:StaticTypeError*/"hi"; |
| 3681 A.x = /*severe:StaticTypeError*/"hi"; |
| 3682 B.y = /*severe:StaticTypeError*/"hi"; |
| 3683 } |
| 3684 '''); |
| 3685 computeResult( |
| 3686 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9); |
| 3687 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; |
| 3688 computeResult( |
| 3689 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9); |
| 3690 CompilationUnit unit2 = outputs[RESOLVED_UNIT9]; |
| 3691 |
| 3692 InterfaceType intType = context.typeProvider.intType; |
| 3693 InterfaceType stringType = context.typeProvider.stringType; |
| 3694 |
| 3695 assertVariableDeclarationTypes( |
| 3696 getTopLevelVariable(unit1, "x"), intType, intType); |
| 3697 assertVariableDeclarationTypes( |
| 3698 getFieldInClass(unit1, "A", "x"), intType, intType); |
| 3699 |
| 3700 assertVariableDeclarationTypes( |
| 3701 getTopLevelVariable(unit2, "y"), intType, intType); |
| 3702 assertVariableDeclarationTypes( |
| 3703 getFieldInClass(unit2, "B", "y"), intType, intType); |
| 3704 |
| 3705 List<Statement> statements = |
| 3706 getStatementsInTopLevelFunction(unit2, "test1"); |
| 3707 |
| 3708 assertAssignmentStatementTypes(statements[0], intType, stringType); |
| 3709 assertAssignmentStatementTypes(statements[1], intType, stringType); |
| 3710 } |
| 3711 |
| 3712 // Test that inference does not propagate from null |
| 3713 void test_perform_inference_cross_unit_static_instance() { |
| 3714 List<Source> sources = newSources({ |
| 3715 '/a.dart': ''' |
| 3716 import 'b.dart'; |
| 3717 class A { |
| 3718 static final a1 = B.b1; |
| 3719 final a2 = new B().b2; |
| 3720 } |
| 3721 ''', |
| 3722 '/b.dart': ''' |
| 3723 class B { |
| 3724 static final b1 = 1; |
| 3725 final b2 = 1; |
| 3726 } |
| 3727 ''', |
| 3728 '/main.dart': ''' |
| 3729 import "a.dart"; |
| 3730 |
| 3731 test1() { |
| 3732 int x = 0; |
| 3733 // inference in A now works. |
| 3734 x = A.a1; |
| 3735 x = new A().a2; |
| 3736 } |
| 3737 ''' |
| 3738 }); |
| 3739 List<dynamic> units = |
| 3740 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); |
| 3741 CompilationUnit unit0 = units[0]; |
| 3742 CompilationUnit unit1 = units[1]; |
| 3743 CompilationUnit unit2 = units[2]; |
| 3744 |
| 3745 InterfaceType intType = context.typeProvider.intType; |
| 3746 |
| 3747 assertVariableDeclarationTypes( |
| 3748 getFieldInClass(unit0, "A", "a1"), intType, intType); |
| 3749 assertVariableDeclarationTypes( |
| 3750 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3751 |
| 3752 assertVariableDeclarationTypes( |
| 3753 getFieldInClass(unit1, "B", "b1"), intType, intType); |
| 3754 assertVariableDeclarationTypes( |
| 3755 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3756 |
| 3757 List<Statement> statements = |
| 3758 getStatementsInTopLevelFunction(unit2, "test1"); |
| 3759 |
| 3760 assertAssignmentStatementTypes(statements[1], intType, intType); |
| 3761 assertAssignmentStatementTypes(statements[2], intType, intType); |
| 3762 } |
| 3763 |
| 3764 // Test inference across units (non-cyclic) |
| 3504 void test_perform_inference_local_variables() { | 3765 void test_perform_inference_local_variables() { |
| 3505 AnalysisTarget source = newSource( | 3766 AnalysisTarget source = newSource( |
| 3506 '/test.dart', | 3767 '/test.dart', |
| 3507 ''' | 3768 ''' |
| 3508 test() { | 3769 test() { |
| 3509 int x = 3; | 3770 int x = 3; |
| 3510 x = "hi"; | 3771 x = "hi"; |
| 3511 var y = 3; | 3772 var y = 3; |
| 3512 y = "hi"; | 3773 y = "hi"; |
| 3513 } | 3774 } |
| 3514 '''); | 3775 '''); |
| 3515 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9); | 3776 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9); |
| 3516 CompilationUnit unit = outputs[RESOLVED_UNIT9]; | 3777 CompilationUnit unit = outputs[RESOLVED_UNIT9]; |
| 3517 | 3778 |
| 3518 InterfaceType intType = context.typeProvider.intType; | 3779 InterfaceType intType = context.typeProvider.intType; |
| 3519 InterfaceType stringType = context.typeProvider.stringType; | 3780 InterfaceType stringType = context.typeProvider.stringType; |
| 3520 | 3781 |
| 3521 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); | 3782 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); |
| 3522 | 3783 |
| 3523 assertVariableDeclarationStatementTypes(statements[0], intType, intType); | 3784 assertVariableDeclarationStatementTypes(statements[0], intType, intType); |
| 3524 assertAssignmentStatementTypes(statements[1], intType, stringType); | 3785 assertAssignmentStatementTypes(statements[1], intType, stringType); |
| 3525 assertVariableDeclarationStatementTypes(statements[2], intType, intType); | 3786 assertVariableDeclarationStatementTypes(statements[2], intType, intType); |
| 3526 assertAssignmentStatementTypes(statements[3], intType, stringType); | 3787 assertAssignmentStatementTypes(statements[3], intType, stringType); |
| 3527 } | 3788 } |
| 3528 | 3789 |
| 3529 // Test inference interactions between local variables and fields | 3790 // Test inference across units (cyclic) |
| 3530 void test_perform_inference_local_variables_fields() { | 3791 void test_perform_inference_local_variables_fields() { |
| 3531 AnalysisTarget source = newSource( | 3792 AnalysisTarget source = newSource( |
| 3532 '/test.dart', | 3793 '/test.dart', |
| 3533 ''' | 3794 ''' |
| 3534 class A { | 3795 class A { |
| 3535 int x = 0; | 3796 int x = 0; |
| 3536 | 3797 |
| 3537 test1() { | 3798 test1() { |
| 3538 var a = x; | 3799 var a = x; |
| 3539 a = "hi"; | 3800 a = "hi"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3569 assertVariableDeclarationStatementTypes(statements[6], intType, intType); | 3830 assertVariableDeclarationStatementTypes(statements[6], intType, intType); |
| 3570 assertAssignmentStatementTypes(statements[7], intType, stringType); | 3831 assertAssignmentStatementTypes(statements[7], intType, stringType); |
| 3571 assertAssignmentStatementTypes(statements[8], intType, intType); | 3832 assertAssignmentStatementTypes(statements[8], intType, intType); |
| 3572 | 3833 |
| 3573 assertVariableDeclarationTypes( | 3834 assertVariableDeclarationTypes( |
| 3574 getFieldInClass(unit, "A", "x"), intType, intType); | 3835 getFieldInClass(unit, "A", "x"), intType, intType); |
| 3575 assertVariableDeclarationTypes( | 3836 assertVariableDeclarationTypes( |
| 3576 getFieldInClass(unit, "A", "z"), intType, intType); | 3837 getFieldInClass(unit, "A", "z"), intType, intType); |
| 3577 } | 3838 } |
| 3578 | 3839 |
| 3579 // Test inference interactions between local variables and top level | 3840 // Test inference of instance fields across units |
| 3580 // variables | |
| 3581 void test_perform_inference_local_variables_topLevel() { | 3841 void test_perform_inference_local_variables_topLevel() { |
| 3582 AnalysisTarget source = newSource( | 3842 AnalysisTarget source = newSource( |
| 3583 '/test.dart', | 3843 '/test.dart', |
| 3584 ''' | 3844 ''' |
| 3585 int x = 0; | 3845 int x = 0; |
| 3586 | 3846 |
| 3587 test1() { | 3847 test1() { |
| 3588 var a = x; | 3848 var a = x; |
| 3589 a = /*severe:StaticTypeError*/"hi"; | 3849 a = /*severe:StaticTypeError*/"hi"; |
| 3590 a = 3; | 3850 a = 3; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3620 assertAssignmentStatementTypes(statements[8], intType, intType); | 3880 assertAssignmentStatementTypes(statements[8], intType, intType); |
| 3621 | 3881 |
| 3622 assertVariableDeclarationTypes( | 3882 assertVariableDeclarationTypes( |
| 3623 getTopLevelVariable(unit, "x"), intType, intType); | 3883 getTopLevelVariable(unit, "x"), intType, intType); |
| 3624 assertVariableDeclarationTypes( | 3884 assertVariableDeclarationTypes( |
| 3625 getTopLevelVariable(unit, "y"), intType, intType); | 3885 getTopLevelVariable(unit, "y"), intType, intType); |
| 3626 assertVariableDeclarationTypes( | 3886 assertVariableDeclarationTypes( |
| 3627 getTopLevelVariable(unit, "z"), intType, intType); | 3887 getTopLevelVariable(unit, "z"), intType, intType); |
| 3628 } | 3888 } |
| 3629 | 3889 |
| 3630 // Test that inference does not propagate from null | 3890 // Test inference between static and instance fields |
| 3631 void test_perform_inference_null() { | 3891 void test_perform_inference_null() { |
| 3632 AnalysisTarget source = newSource( | 3892 AnalysisTarget source = newSource( |
| 3633 '/test.dart', | 3893 '/test.dart', |
| 3634 ''' | 3894 ''' |
| 3635 var x = null; | 3895 var x = null; |
| 3636 var y = 3; | 3896 var y = 3; |
| 3637 class A { | 3897 class A { |
| 3638 static var x = null; | 3898 static var x = null; |
| 3639 static var y = 3; | 3899 static var y = 3; |
| 3640 | 3900 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3675 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); | 3935 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); |
| 3676 | 3936 |
| 3677 assertAssignmentStatementTypes(statements[0], dynamicType, stringType); | 3937 assertAssignmentStatementTypes(statements[0], dynamicType, stringType); |
| 3678 assertAssignmentStatementTypes(statements[1], intType, stringType); | 3938 assertAssignmentStatementTypes(statements[1], intType, stringType); |
| 3679 assertAssignmentStatementTypes(statements[2], dynamicType, stringType); | 3939 assertAssignmentStatementTypes(statements[2], dynamicType, stringType); |
| 3680 assertAssignmentStatementTypes(statements[3], intType, stringType); | 3940 assertAssignmentStatementTypes(statements[3], intType, stringType); |
| 3681 assertAssignmentStatementTypes(statements[4], dynamicType, stringType); | 3941 assertAssignmentStatementTypes(statements[4], dynamicType, stringType); |
| 3682 assertAssignmentStatementTypes(statements[5], intType, stringType); | 3942 assertAssignmentStatementTypes(statements[5], intType, stringType); |
| 3683 } | 3943 } |
| 3684 | 3944 |
| 3685 // Test inference across units (non-cyclic) | 3945 // Test inference between fields and method bodies |
| 3686 void test_perform_inference_cross_unit_non_cyclic() { | 3946 void test_perform_local_explicit_disabled() { |
| 3687 AnalysisTarget firstSource = newSource( | 3947 AnalysisTarget source = newSource( |
| 3688 '/a.dart', | |
| 3689 ''' | |
| 3690 var x = 2; | |
| 3691 class A { static var x = 2; } | |
| 3692 '''); | |
| 3693 AnalysisTarget secondSource = newSource( | |
| 3694 '/test.dart', | 3948 '/test.dart', |
| 3695 ''' | 3949 ''' |
| 3696 import 'a.dart'; | 3950 test() { |
| 3697 var y = x; | 3951 int x = 3; |
| 3698 class B { static var y = A.x; } | 3952 x = "hi"; |
| 3699 | 3953 } |
| 3700 test1() { | |
| 3701 x = /*severe:StaticTypeError*/"hi"; | |
| 3702 y = /*severe:StaticTypeError*/"hi"; | |
| 3703 A.x = /*severe:StaticTypeError*/"hi"; | |
| 3704 B.y = /*severe:StaticTypeError*/"hi"; | |
| 3705 } | |
| 3706 '''); | 3954 '''); |
| 3707 computeResult( | 3955 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9); |
| 3708 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9); | 3956 CompilationUnit unit = outputs[RESOLVED_UNIT9]; |
| 3709 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; | |
| 3710 computeResult( | |
| 3711 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9); | |
| 3712 CompilationUnit unit2 = outputs[RESOLVED_UNIT9]; | |
| 3713 | 3957 |
| 3714 InterfaceType intType = context.typeProvider.intType; | 3958 InterfaceType intType = context.typeProvider.intType; |
| 3715 InterfaceType stringType = context.typeProvider.stringType; | 3959 InterfaceType stringType = context.typeProvider.stringType; |
| 3716 | 3960 |
| 3717 assertVariableDeclarationTypes( | 3961 List<Statement> statements = getStatementsInTopLevelFunction(unit, "test"); |
| 3718 getTopLevelVariable(unit1, "x"), intType, intType); | 3962 VariableDeclaration decl = |
| 3719 assertVariableDeclarationTypes( | 3963 (statements[0] as VariableDeclarationStatement).variables.variables[0]; |
| 3720 getFieldInClass(unit1, "A", "x"), intType, intType); | 3964 expect(decl.element.type, intType); |
| 3965 expect(decl.initializer.staticType, intType); |
| 3721 | 3966 |
| 3722 assertVariableDeclarationTypes( | 3967 ExpressionStatement statement = statements[1]; |
| 3723 getTopLevelVariable(unit2, "y"), intType, intType); | 3968 AssignmentExpression assgn = statement.expression; |
| 3724 assertVariableDeclarationTypes( | 3969 expect(assgn.leftHandSide.staticType, intType); |
| 3725 getFieldInClass(unit2, "B", "y"), intType, intType); | 3970 expect(assgn.rightHandSide.staticType, stringType); |
| 3726 | |
| 3727 List<Statement> statements = | |
| 3728 getStatementsInTopLevelFunction(unit2, "test1"); | |
| 3729 | |
| 3730 assertAssignmentStatementTypes(statements[0], intType, stringType); | |
| 3731 assertAssignmentStatementTypes(statements[1], intType, stringType); | |
| 3732 } | |
| 3733 | |
| 3734 // Test inference across units (cyclic) | |
| 3735 void test_perform_inference_cross_unit_cyclic() { | |
| 3736 AnalysisTarget firstSource = newSource( | |
| 3737 '/a.dart', | |
| 3738 ''' | |
| 3739 import 'test.dart'; | |
| 3740 var x = 2; | |
| 3741 class A { static var x = 2; } | |
| 3742 '''); | |
| 3743 AnalysisTarget secondSource = newSource( | |
| 3744 '/test.dart', | |
| 3745 ''' | |
| 3746 import 'a.dart'; | |
| 3747 var y = x; | |
| 3748 class B { static var y = A.x; } | |
| 3749 | |
| 3750 test1() { | |
| 3751 int t = 3; | |
| 3752 t = x; | |
| 3753 t = y; | |
| 3754 t = A.x; | |
| 3755 t = B.y; | |
| 3756 } | |
| 3757 '''); | |
| 3758 computeResult( | |
| 3759 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9); | |
| 3760 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; | |
| 3761 computeResult( | |
| 3762 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9); | |
| 3763 CompilationUnit unit2 = outputs[RESOLVED_UNIT9]; | |
| 3764 | |
| 3765 InterfaceType intType = context.typeProvider.intType; | |
| 3766 | |
| 3767 assertVariableDeclarationTypes( | |
| 3768 getTopLevelVariable(unit1, "x"), intType, intType); | |
| 3769 assertVariableDeclarationTypes( | |
| 3770 getFieldInClass(unit1, "A", "x"), intType, intType); | |
| 3771 | |
| 3772 assertVariableDeclarationTypes( | |
| 3773 getTopLevelVariable(unit2, "y"), intType, intType); | |
| 3774 assertVariableDeclarationTypes( | |
| 3775 getFieldInClass(unit2, "B", "y"), intType, intType); | |
| 3776 | |
| 3777 List<Statement> statements = | |
| 3778 getStatementsInTopLevelFunction(unit2, "test1"); | |
| 3779 | |
| 3780 assertAssignmentStatementTypes(statements[1], intType, intType); | |
| 3781 assertAssignmentStatementTypes(statements[2], intType, intType); | |
| 3782 assertAssignmentStatementTypes(statements[3], intType, intType); | |
| 3783 assertAssignmentStatementTypes(statements[4], intType, intType); | |
| 3784 } | |
| 3785 | |
| 3786 // Test inference of instance fields across units | |
| 3787 void test_perform_inference_cross_unit_instance() { | |
| 3788 List<Source> sources = newSources({ | |
| 3789 '/a.dart': ''' | |
| 3790 import 'b.dart'; | |
| 3791 class A { | |
| 3792 final a2 = new B().b2; | |
| 3793 } | |
| 3794 ''', | |
| 3795 '/b.dart': ''' | |
| 3796 class B { | |
| 3797 final b2 = 1; | |
| 3798 } | |
| 3799 ''', | |
| 3800 '/main.dart': ''' | |
| 3801 import "a.dart"; | |
| 3802 | |
| 3803 test1() { | |
| 3804 int x = 0; | |
| 3805 x = new A().a2; | |
| 3806 } | |
| 3807 ''' | |
| 3808 }); | |
| 3809 List<dynamic> units = | |
| 3810 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); | |
| 3811 CompilationUnit unit0 = units[0]; | |
| 3812 CompilationUnit unit1 = units[1]; | |
| 3813 CompilationUnit unit2 = units[2]; | |
| 3814 | |
| 3815 InterfaceType intType = context.typeProvider.intType; | |
| 3816 | |
| 3817 assertVariableDeclarationTypes( | |
| 3818 getFieldInClass(unit0, "A", "a2"), intType, intType); | |
| 3819 | |
| 3820 assertVariableDeclarationTypes( | |
| 3821 getFieldInClass(unit1, "B", "b2"), intType, intType); | |
| 3822 | |
| 3823 List<Statement> statements = | |
| 3824 getStatementsInTopLevelFunction(unit2, "test1"); | |
| 3825 | |
| 3826 assertAssignmentStatementTypes(statements[1], intType, intType); | |
| 3827 } | |
| 3828 | |
| 3829 // Test inference between static and instance fields | |
| 3830 void test_perform_inference_cross_unit_static_instance() { | |
| 3831 List<Source> sources = newSources({ | |
| 3832 '/a.dart': ''' | |
| 3833 import 'b.dart'; | |
| 3834 class A { | |
| 3835 static final a1 = B.b1; | |
| 3836 final a2 = new B().b2; | |
| 3837 } | |
| 3838 ''', | |
| 3839 '/b.dart': ''' | |
| 3840 class B { | |
| 3841 static final b1 = 1; | |
| 3842 final b2 = 1; | |
| 3843 } | |
| 3844 ''', | |
| 3845 '/main.dart': ''' | |
| 3846 import "a.dart"; | |
| 3847 | |
| 3848 test1() { | |
| 3849 int x = 0; | |
| 3850 // inference in A now works. | |
| 3851 x = A.a1; | |
| 3852 x = new A().a2; | |
| 3853 } | |
| 3854 ''' | |
| 3855 }); | |
| 3856 List<dynamic> units = | |
| 3857 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); | |
| 3858 CompilationUnit unit0 = units[0]; | |
| 3859 CompilationUnit unit1 = units[1]; | |
| 3860 CompilationUnit unit2 = units[2]; | |
| 3861 | |
| 3862 InterfaceType intType = context.typeProvider.intType; | |
| 3863 | |
| 3864 assertVariableDeclarationTypes( | |
| 3865 getFieldInClass(unit0, "A", "a1"), intType, intType); | |
| 3866 assertVariableDeclarationTypes( | |
| 3867 getFieldInClass(unit0, "A", "a2"), intType, intType); | |
| 3868 | |
| 3869 assertVariableDeclarationTypes( | |
| 3870 getFieldInClass(unit1, "B", "b1"), intType, intType); | |
| 3871 assertVariableDeclarationTypes( | |
| 3872 getFieldInClass(unit1, "B", "b2"), intType, intType); | |
| 3873 | |
| 3874 List<Statement> statements = | |
| 3875 getStatementsInTopLevelFunction(unit2, "test1"); | |
| 3876 | |
| 3877 assertAssignmentStatementTypes(statements[1], intType, intType); | |
| 3878 assertAssignmentStatementTypes(statements[2], intType, intType); | |
| 3879 } | |
| 3880 | |
| 3881 // Test inference between fields and method bodies | |
| 3882 void test_perform_inference_cross_unit_instance_member() { | |
| 3883 List<Source> sources = newSources({ | |
| 3884 '/a.dart': ''' | |
| 3885 import 'b.dart'; | |
| 3886 var bar = new B(); | |
| 3887 void foo() { | |
| 3888 String x = bar.f.z; | |
| 3889 } | |
| 3890 ''', | |
| 3891 '/b.dart': ''' | |
| 3892 class C { | |
| 3893 var z = 3; | |
| 3894 } | |
| 3895 | |
| 3896 class B { | |
| 3897 var f = new C(); | |
| 3898 } | |
| 3899 ''', | |
| 3900 '/c.dart': ''' | |
| 3901 import 'b.dart'; | |
| 3902 var bar = new B(); | |
| 3903 void foo() { | |
| 3904 String x = bar.f.z; | |
| 3905 } | |
| 3906 ''' | |
| 3907 }); | |
| 3908 List<dynamic> units = | |
| 3909 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); | |
| 3910 CompilationUnit unit0 = units[0]; | |
| 3911 CompilationUnit unit1 = units[1]; | |
| 3912 CompilationUnit unit2 = units[2]; | |
| 3913 | |
| 3914 InterfaceType intType = context.typeProvider.intType; | |
| 3915 InterfaceType stringType = context.typeProvider.stringType; | |
| 3916 | |
| 3917 assertVariableDeclarationStatementTypes( | |
| 3918 getStatementsInTopLevelFunction(unit0, "foo")[0], stringType, intType); | |
| 3919 assertVariableDeclarationStatementTypes( | |
| 3920 getStatementsInTopLevelFunction(unit2, "foo")[0], stringType, intType); | |
| 3921 } | 3971 } |
| 3922 } | 3972 } |
| 3923 | 3973 |
| 3924 @reflectiveTest | 3974 @reflectiveTest |
| 3925 class VerifyUnitTaskTest extends _AbstractDartTaskTest { | 3975 class VerifyUnitTaskTest extends _AbstractDartTaskTest { |
| 3926 test_perform_constantError() { | 3976 test_perform_constantError() { |
| 3927 Source source = newSource( | 3977 Source source = newSource( |
| 3928 '/test.dart', | 3978 '/test.dart', |
| 3929 ''' | 3979 ''' |
| 3930 main(int p) { | 3980 main(int p) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4013 } | 4063 } |
| 4014 | 4064 |
| 4015 void assertSameResults(List<ResultDescriptor> descriptors) { | 4065 void assertSameResults(List<ResultDescriptor> descriptors) { |
| 4016 descriptors.forEach((descriptor) { | 4066 descriptors.forEach((descriptor) { |
| 4017 var oldResult = oldOutputs[descriptor]; | 4067 var oldResult = oldOutputs[descriptor]; |
| 4018 var newResult = outputs[descriptor]; | 4068 var newResult = outputs[descriptor]; |
| 4019 expect(newResult, same(oldResult), reason: descriptor.name); | 4069 expect(newResult, same(oldResult), reason: descriptor.name); |
| 4020 }); | 4070 }); |
| 4021 } | 4071 } |
| 4022 | 4072 |
| 4023 void assertVariableDeclarationTypes( | |
| 4024 VariableDeclaration decl, DartType varType, DartType initializerType) { | |
| 4025 expect(decl.element.type, varType); | |
| 4026 expect(decl.initializer.staticType, initializerType); | |
| 4027 } | |
| 4028 | |
| 4029 void assertVariableDeclarationStatementTypes( | 4073 void assertVariableDeclarationStatementTypes( |
| 4030 Statement stmt, DartType varType, DartType initializerType) { | 4074 Statement stmt, DartType varType, DartType initializerType) { |
| 4031 VariableDeclaration decl = | 4075 VariableDeclaration decl = |
| 4032 (stmt as VariableDeclarationStatement).variables.variables[0]; | 4076 (stmt as VariableDeclarationStatement).variables.variables[0]; |
| 4033 assertVariableDeclarationTypes(decl, varType, initializerType); | 4077 assertVariableDeclarationTypes(decl, varType, initializerType); |
| 4034 } | 4078 } |
| 4035 | 4079 |
| 4080 void assertVariableDeclarationTypes( |
| 4081 VariableDeclaration decl, DartType varType, DartType initializerType) { |
| 4082 expect(decl.element.type, varType); |
| 4083 expect(decl.initializer.staticType, initializerType); |
| 4084 } |
| 4085 |
| 4036 List<dynamic> computeLibraryResults( | 4086 List<dynamic> computeLibraryResults( |
| 4037 List<Source> sources, ResultDescriptor result, | 4087 List<Source> sources, ResultDescriptor result, |
| 4038 {isInstanceOf matcher: null}) { | 4088 {isInstanceOf matcher: null}) { |
| 4039 dynamic compute(Source source) { | 4089 dynamic compute(Source source) { |
| 4040 computeResult(new LibrarySpecificUnit(source, source), result, | 4090 computeResult(new LibrarySpecificUnit(source, source), result, |
| 4041 matcher: matcher); | 4091 matcher: matcher); |
| 4042 return outputs[result]; | 4092 return outputs[result]; |
| 4043 } | 4093 } |
| 4044 return sources.map(compute).toList(); | 4094 return sources.map(compute).toList(); |
| 4045 } | 4095 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4200 /** | 4250 /** |
| 4201 * Fill [errorListener] with [result] errors in the current [task]. | 4251 * Fill [errorListener] with [result] errors in the current [task]. |
| 4202 */ | 4252 */ |
| 4203 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4253 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 4204 List<AnalysisError> errors = task.outputs[result]; | 4254 List<AnalysisError> errors = task.outputs[result]; |
| 4205 expect(errors, isNotNull, reason: result.name); | 4255 expect(errors, isNotNull, reason: result.name); |
| 4206 errorListener = new GatheringErrorListener(); | 4256 errorListener = new GatheringErrorListener(); |
| 4207 errorListener.addAll(errors); | 4257 errorListener.addAll(errors); |
| 4208 } | 4258 } |
| 4209 } | 4259 } |
| OLD | NEW |