| 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 3637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3648 /** | 3648 /** |
| 3649 * For each class declaration, this method is called which verifies that all | 3649 * For each class declaration, this method is called which verifies that all |
| 3650 * inherited members are inherited consistently. | 3650 * inherited members are inherited consistently. |
| 3651 * | 3651 * |
| 3652 * See [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]. | 3652 * See [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]. |
| 3653 */ | 3653 */ |
| 3654 void _checkForInconsistentMethodInheritance() { | 3654 void _checkForInconsistentMethodInheritance() { |
| 3655 // Ensure that the inheritance manager has a chance to generate all errors | 3655 // Ensure that the inheritance manager has a chance to generate all errors |
| 3656 // we may care about, note that we ensure that the interfaces data since | 3656 // we may care about, note that we ensure that the interfaces data since |
| 3657 // there are no errors. | 3657 // there are no errors. |
| 3658 _inheritanceManager.getMapOfMembersInheritedFromInterfaces(_enclosingClass); | 3658 _inheritanceManager.getMembersInheritedFromInterfaces(_enclosingClass); |
| 3659 HashSet<AnalysisError> errors = | 3659 Set<AnalysisError> errors = _inheritanceManager.getErrors(_enclosingClass); |
| 3660 _inheritanceManager.getErrors(_enclosingClass); | |
| 3661 if (errors == null || errors.isEmpty) { | 3660 if (errors == null || errors.isEmpty) { |
| 3662 return; | 3661 return; |
| 3663 } | 3662 } |
| 3664 for (AnalysisError error in errors) { | 3663 for (AnalysisError error in errors) { |
| 3665 _errorReporter.reportError(error); | 3664 _errorReporter.reportError(error); |
| 3666 } | 3665 } |
| 3667 return; | 3666 return; |
| 3668 } | 3667 } |
| 3669 | 3668 |
| 3670 /** | 3669 /** |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4519 } | 4518 } |
| 4520 // | 4519 // |
| 4521 // Store in local sets the set of all method and accessor names | 4520 // Store in local sets the set of all method and accessor names |
| 4522 // | 4521 // |
| 4523 HashSet<ExecutableElement> missingOverrides = | 4522 HashSet<ExecutableElement> missingOverrides = |
| 4524 new HashSet<ExecutableElement>(); | 4523 new HashSet<ExecutableElement>(); |
| 4525 // | 4524 // |
| 4526 // Loop through the set of all executable elements declared in the implicit | 4525 // Loop through the set of all executable elements declared in the implicit |
| 4527 // interface. | 4526 // interface. |
| 4528 // | 4527 // |
| 4529 MemberMap membersInheritedFromInterfaces = _inheritanceManager | 4528 Map<String, ExecutableElement> membersInheritedFromInterfaces = |
| 4530 .getMapOfMembersInheritedFromInterfaces(_enclosingClass); | 4529 _inheritanceManager.getMembersInheritedFromInterfaces(_enclosingClass); |
| 4531 MemberMap membersInheritedFromSuperclasses = _inheritanceManager | 4530 Map<String, ExecutableElement> membersInheritedFromSuperclasses = |
| 4532 .getMapOfMembersInheritedFromClasses(_enclosingClass); | 4531 _inheritanceManager.getMembersInheritedFromClasses(_enclosingClass); |
| 4533 for (int i = 0; i < membersInheritedFromInterfaces.size; i++) { | 4532 for (String memberName in membersInheritedFromInterfaces.keys) { |
| 4534 String memberName = membersInheritedFromInterfaces.getKey(i); | |
| 4535 ExecutableElement executableElt = | 4533 ExecutableElement executableElt = |
| 4536 membersInheritedFromInterfaces.getValue(i); | 4534 membersInheritedFromInterfaces[memberName]; |
| 4537 if (memberName == null) { | 4535 if (memberName == null) { |
| 4538 break; | 4536 break; |
| 4539 } | 4537 } |
| 4540 // If the element is not synthetic and can be determined to be defined in | 4538 // If the element is not synthetic and can be determined to be defined in |
| 4541 // Object, skip it. | 4539 // Object, skip it. |
| 4542 if (executableElt.enclosingElement != null && | 4540 if (executableElt.enclosingElement != null && |
| 4543 (executableElt.enclosingElement as ClassElement).type.isObject) { | 4541 (executableElt.enclosingElement as ClassElement).type.isObject) { |
| 4544 continue; | 4542 continue; |
| 4545 } | 4543 } |
| 4546 // Check to see if some element is in local enclosing class that matches | 4544 // Check to see if some element is in local enclosing class that matches |
| 4547 // the name of the required member. | 4545 // the name of the required member. |
| 4548 if (_isMemberInClassOrMixin(executableElt, _enclosingClass)) { | 4546 if (_isMemberInClassOrMixin(executableElt, _enclosingClass)) { |
| 4549 // We do not have to verify that this implementation of the found method | 4547 // We do not have to verify that this implementation of the found method |
| 4550 // matches the required function type: the set of | 4548 // matches the required function type: the set of |
| 4551 // StaticWarningCode.INVALID_METHOD_OVERRIDE_* warnings break out the | 4549 // StaticWarningCode.INVALID_METHOD_OVERRIDE_* warnings break out the |
| 4552 // different specific situations. | 4550 // different specific situations. |
| 4553 continue; | 4551 continue; |
| 4554 } | 4552 } |
| 4555 // First check to see if this element was declared in the superclass | 4553 // First check to see if this element was declared in the superclass |
| 4556 // chain, in which case there is already a concrete implementation. | 4554 // chain, in which case there is already a concrete implementation. |
| 4557 ExecutableElement elt = membersInheritedFromSuperclasses.get(memberName); | 4555 ExecutableElement elt = membersInheritedFromSuperclasses[memberName]; |
| 4558 // Check to see if an element was found in the superclass chain with the | 4556 // Check to see if an element was found in the superclass chain with the |
| 4559 // correct name. | 4557 // correct name. |
| 4560 if (elt != null) { | 4558 if (elt != null) { |
| 4561 // Reference the types, if any are null then continue. | 4559 // Reference the types, if any are null then continue. |
| 4562 InterfaceType enclosingType = _enclosingClass.type; | 4560 InterfaceType enclosingType = _enclosingClass.type; |
| 4563 FunctionType concreteType = elt.type; | 4561 FunctionType concreteType = elt.type; |
| 4564 FunctionType requiredMemberType = executableElt.type; | 4562 FunctionType requiredMemberType = executableElt.type; |
| 4565 if (enclosingType == null || | 4563 if (enclosingType == null || |
| 4566 concreteType == null || | 4564 concreteType == null || |
| 4567 requiredMemberType == null) { | 4565 requiredMemberType == null) { |
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6163 class _InvocationCollector extends RecursiveAstVisitor { | 6161 class _InvocationCollector extends RecursiveAstVisitor { |
| 6164 final List<String> superCalls = <String>[]; | 6162 final List<String> superCalls = <String>[]; |
| 6165 | 6163 |
| 6166 @override | 6164 @override |
| 6167 visitMethodInvocation(MethodInvocation node) { | 6165 visitMethodInvocation(MethodInvocation node) { |
| 6168 if (node.target is SuperExpression) { | 6166 if (node.target is SuperExpression) { |
| 6169 superCalls.add(node.methodName.name); | 6167 superCalls.add(node.methodName.name); |
| 6170 } | 6168 } |
| 6171 } | 6169 } |
| 6172 } | 6170 } |
| OLD | NEW |