Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java

Issue 14406002: Supress the undefined-method warning when noSuchMethod() is declared in the targetType of the metho… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
index e3e81c744a881b2c9c2934d1a1d247b7747ffd7f..0b3041f2c47492330bdaf3983c4d0c2d5003834a 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
@@ -646,11 +646,13 @@ public class ElementResolver extends SimpleASTVisitor<Void> {
methodName,
methodName.getName());
} else {
- resolver.reportError(
- StaticTypeWarningCode.UNDEFINED_METHOD,
- methodName,
- methodName.getName(),
- targetTypeName);
+ if (!doesClassDeclareNoSuchMethod(targetType.getElement())) {
+ resolver.reportError(
+ StaticTypeWarningCode.UNDEFINED_METHOD,
+ methodName,
+ methodName.getName(),
+ targetTypeName);
+ }
}
}
return null;
@@ -1003,6 +1005,29 @@ public class ElementResolver extends SimpleASTVisitor<Void> {
}
/**
+ * Return {@code true} if the passed {@link Element} is a {@link ClassElement} that declares a
+ * method "noSuchMethod".
+ *
+ * @param element the {@link Element} to evaluate
+ * @return {@code true} if the passed {@link Element} is a {@link ClassElement} that declares a
+ * method "noSuchMethod"
+ */
+ private boolean doesClassDeclareNoSuchMethod(Element element) {
+ if (element == null) {
+ return false;
+ }
+ if (!(element instanceof ClassElementImpl)) {
+ return false;
+ }
+ ClassElementImpl classElement = (ClassElementImpl) element;
+ MethodElement method = classElement.getMethod("noSuchMethod");
+ if (method == null) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Search through the array of parameters for a parameter whose name matches the given name.
* Return the parameter with the given name, or {@code null} if there is no such parameter.
*
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698