Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
index 2610ff3a79837bb12abc1341896fcc5712a5ffcc..6bade4ee6992e255e5ad9a4e33b22b21dd55c45e 100644 |
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
@@ -814,6 +814,8 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
checkForOptionalParameterInOperator(node); |
checkForWrongNumberOfParametersForOperator(node); |
checkForNonVoidReturnTypeForOperator(node); |
+ } else { |
+ checkForConflictingInstanceMethodSetter(node); |
} |
checkForConcreteClassWithAbstractMember(node); |
checkForAllInvalidOverrideErrorCodes(node); |
@@ -2262,6 +2264,47 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
} |
/** |
+ * This verifies that the enclosing class does not have a setter with the same name as the passed |
+ * instance method declaration. |
+ * |
+ * @param node the method declaration to evaluate |
+ * @return {@code true} if and only if an error code is generated on the passed node |
+ * @see StaticWarningCode#CONFLICTING_INSTANCE_METHOD_SETTER |
+ */ |
+ private boolean checkForConflictingInstanceMethodSetter(MethodDeclaration node) { |
+ if (node.isStatic()) { |
+ return false; |
+ } |
+ // prepare name |
+ SimpleIdentifier nameNode = node.getName(); |
+ if (nameNode == null) { |
+ return false; |
+ } |
+ String name = nameNode.getName(); |
+ // prepare enclosing type |
+ if (enclosingClass == null) { |
+ return false; |
+ } |
+ InterfaceType enclosingType = enclosingClass.getType(); |
+ // try to find setter |
+ ExecutableElement setter = enclosingType.lookUpSetter(name, currentLibrary); |
Brian Wilkerson
2013/11/02 15:19:38
Should this be using the InheritanceManager to do
scheglov
2013/11/02 20:32:00
Yes, we need to use InheritanceManager.
Fixed.
|
+ if (setter == null) { |
+ return false; |
+ } |
+ // already reported as INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC |
+ if (setter.isStatic()) { |
+ return false; |
+ } |
+ // report problem |
+ errorReporter.reportError( |
+ StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER, |
+ nameNode, |
+ enclosingType.getDisplayName(), |
+ name); |
+ return true; |
+ } |
+ |
+ /** |
* This verifies that the enclosing class does not have an instance member with the same name as |
* the passed static getter method declaration. |
* |