OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.src.generated.error_verifier; | 5 library analyzer.src.generated.error_verifier; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 * [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE], | 1432 * [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE], |
1433 * [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE], and | 1433 * [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE], and |
1434 * [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES]. | 1434 * [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES]. |
1435 */ | 1435 */ |
1436 bool _checkForAllInvalidOverrideErrorCodes( | 1436 bool _checkForAllInvalidOverrideErrorCodes( |
1437 ExecutableElement derivedElement, | 1437 ExecutableElement derivedElement, |
1438 ExecutableElement baseElement, | 1438 ExecutableElement baseElement, |
1439 List<ParameterElement> parameters, | 1439 List<ParameterElement> parameters, |
1440 List<AstNode> parameterLocations, | 1440 List<AstNode> parameterLocations, |
1441 SimpleIdentifier errorNameTarget) { | 1441 SimpleIdentifier errorNameTarget) { |
| 1442 if (_options.strongMode) { |
| 1443 return false; // strong mode already checked for this |
| 1444 } |
| 1445 |
1442 bool isGetter = false; | 1446 bool isGetter = false; |
1443 bool isSetter = false; | 1447 bool isSetter = false; |
1444 if (derivedElement is PropertyAccessorElement) { | 1448 if (derivedElement is PropertyAccessorElement) { |
1445 isGetter = derivedElement.isGetter; | 1449 isGetter = derivedElement.isGetter; |
1446 isSetter = derivedElement.isSetter; | 1450 isSetter = derivedElement.isSetter; |
1447 } | 1451 } |
1448 String executableElementName = derivedElement.name; | 1452 String executableElementName = derivedElement.name; |
1449 FunctionType derivedFT = derivedElement.type; | 1453 FunctionType derivedFT = derivedElement.type; |
1450 FunctionType baseFT = baseElement.type; | 1454 FunctionType baseFT = baseElement.type; |
1451 InterfaceType enclosingType = _enclosingClass.type; | 1455 InterfaceType enclosingType = _enclosingClass.type; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 * returns a [MultiplyInheritedExecutableElement], this method loops through | 1775 * returns a [MultiplyInheritedExecutableElement], this method loops through |
1772 * the list in the [MultiplyInheritedExecutableElement]. The [parameters] are | 1776 * the list in the [MultiplyInheritedExecutableElement]. The [parameters] are |
1773 * the parameters of the executable element. The [errorNameTarget] is the node | 1777 * the parameters of the executable element. The [errorNameTarget] is the node |
1774 * to report problems on. | 1778 * to report problems on. |
1775 */ | 1779 */ |
1776 void _checkForAllInvalidOverrideErrorCodesForExecutable( | 1780 void _checkForAllInvalidOverrideErrorCodesForExecutable( |
1777 ExecutableElement executableElement, | 1781 ExecutableElement executableElement, |
1778 List<ParameterElement> parameters, | 1782 List<ParameterElement> parameters, |
1779 List<AstNode> parameterLocations, | 1783 List<AstNode> parameterLocations, |
1780 SimpleIdentifier errorNameTarget) { | 1784 SimpleIdentifier errorNameTarget) { |
| 1785 assert(!_options.strongMode); // strong mode already checked for these |
1781 // | 1786 // |
1782 // Compute the overridden executable from the InheritanceManager | 1787 // Compute the overridden executable from the InheritanceManager |
1783 // | 1788 // |
1784 List<ExecutableElement> overriddenExecutables = _inheritanceManager | 1789 List<ExecutableElement> overriddenExecutables = _inheritanceManager |
1785 .lookupOverrides(_enclosingClass, executableElement.name); | 1790 .lookupOverrides(_enclosingClass, executableElement.name); |
1786 if (_checkForInstanceMethodNameCollidesWithSuperclassStatic( | 1791 if (_checkForInstanceMethodNameCollidesWithSuperclassStatic( |
1787 executableElement, errorNameTarget)) { | 1792 executableElement, errorNameTarget)) { |
1788 return; | 1793 return; |
1789 } | 1794 } |
1790 for (ExecutableElement overriddenElement in overriddenExecutables) { | 1795 for (ExecutableElement overriddenElement in overriddenExecutables) { |
1791 if (_checkForAllInvalidOverrideErrorCodes(executableElement, | 1796 if (_checkForAllInvalidOverrideErrorCodes(executableElement, |
1792 overriddenElement, parameters, parameterLocations, errorNameTarget)) { | 1797 overriddenElement, parameters, parameterLocations, errorNameTarget)) { |
1793 return; | 1798 return; |
1794 } | 1799 } |
1795 } | 1800 } |
1796 } | 1801 } |
1797 | 1802 |
1798 /** | 1803 /** |
1799 * Check the given field [declaration] against override-error codes. | 1804 * Check the given field [declaration] against override-error codes. |
1800 * | 1805 * |
1801 * See [_checkForAllInvalidOverrideErrorCodes]. | 1806 * See [_checkForAllInvalidOverrideErrorCodes]. |
1802 */ | 1807 */ |
1803 void _checkForAllInvalidOverrideErrorCodesForField( | 1808 void _checkForAllInvalidOverrideErrorCodesForField( |
1804 FieldDeclaration declaration) { | 1809 FieldDeclaration declaration) { |
| 1810 if (_options.strongMode) { |
| 1811 return; // strong mode already checked for this |
| 1812 } |
| 1813 |
1805 if (_enclosingClass == null || declaration.isStatic) { | 1814 if (_enclosingClass == null || declaration.isStatic) { |
1806 return; | 1815 return; |
1807 } | 1816 } |
1808 | 1817 |
1809 VariableDeclarationList fields = declaration.fields; | 1818 VariableDeclarationList fields = declaration.fields; |
1810 for (VariableDeclaration field in fields.variables) { | 1819 for (VariableDeclaration field in fields.variables) { |
1811 FieldElement element = field.element as FieldElement; | 1820 FieldElement element = field.element as FieldElement; |
1812 if (element == null) { | 1821 if (element == null) { |
1813 continue; | 1822 continue; |
1814 } | 1823 } |
(...skipping 11 matching lines...) Expand all Loading... |
1826 } | 1835 } |
1827 } | 1836 } |
1828 | 1837 |
1829 /** | 1838 /** |
1830 * Check the given [method] declaration against override-error codes. | 1839 * Check the given [method] declaration against override-error codes. |
1831 * | 1840 * |
1832 * See [_checkForAllInvalidOverrideErrorCodes]. | 1841 * See [_checkForAllInvalidOverrideErrorCodes]. |
1833 */ | 1842 */ |
1834 void _checkForAllInvalidOverrideErrorCodesForMethod( | 1843 void _checkForAllInvalidOverrideErrorCodesForMethod( |
1835 MethodDeclaration method) { | 1844 MethodDeclaration method) { |
| 1845 if (_options.strongMode) { |
| 1846 return; // strong mode already checked for this |
| 1847 } |
1836 if (_enclosingClass == null || | 1848 if (_enclosingClass == null || |
1837 method.isStatic || | 1849 method.isStatic || |
1838 method.body is NativeFunctionBody) { | 1850 method.body is NativeFunctionBody) { |
1839 return; | 1851 return; |
1840 } | 1852 } |
1841 ExecutableElement executableElement = method.element; | 1853 ExecutableElement executableElement = method.element; |
1842 if (executableElement == null) { | 1854 if (executableElement == null) { |
1843 return; | 1855 return; |
1844 } | 1856 } |
1845 SimpleIdentifier methodName = method.name; | 1857 SimpleIdentifier methodName = method.name; |
(...skipping 4611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6457 class _InvocationCollector extends RecursiveAstVisitor { | 6469 class _InvocationCollector extends RecursiveAstVisitor { |
6458 final List<String> superCalls = <String>[]; | 6470 final List<String> superCalls = <String>[]; |
6459 | 6471 |
6460 @override | 6472 @override |
6461 visitMethodInvocation(MethodInvocation node) { | 6473 visitMethodInvocation(MethodInvocation node) { |
6462 if (node.target is SuperExpression) { | 6474 if (node.target is SuperExpression) { |
6463 superCalls.add(node.methodName.name); | 6475 superCalls.add(node.methodName.name); |
6464 } | 6476 } |
6465 } | 6477 } |
6466 } | 6478 } |
OLD | NEW |