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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1414003003: Do not generate warnings when noSuchMethod is inherited (issue 24337) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 7c8516e7343bf4a9f0e7f08177a8ee1baaa3c655..ec9559a0fee3b5cf31e84c344daf6d4ebb463e76 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -2157,7 +2157,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
overriddenMember = _enclosingClass.lookUpInheritedConcreteMethod(
memberName, _currentLibrary);
}
- if (overriddenMember == null) {
+ if (overriddenMember == null && !_hasNoSuchMethod(_enclosingClass)) {
_errorReporter.reportErrorForNode(
StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
nameNode,
@@ -4422,19 +4422,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
SimpleIdentifier classNameNode) {
if (_enclosingClass.isAbstract) {
return false;
+ } else if (_hasNoSuchMethod(_enclosingClass)) {
+ return false;
}
//
// Store in local sets the set of all method and accessor names
//
- MethodElement method =
- _enclosingClass.getMethod(FunctionElement.NO_SUCH_METHOD_METHOD_NAME);
- if (method != null) {
- // If the enclosing class declares the method noSuchMethod(), then return.
- // From Spec: It is a static warning if a concrete class does not have an
- // implementation for a method in any of its superinterfaces unless it
- // declares its own noSuchMethod method (7.10).
- return false;
- }
HashSet<ExecutableElement> missingOverrides =
new HashSet<ExecutableElement>();
//
@@ -5596,8 +5589,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
// If there is a noSuchMethod method, then don't report the warning,
// see dartbug.com/16078
- if (classElement.getMethod(FunctionElement.NO_SUCH_METHOD_METHOD_NAME) !=
- null) {
+ if (_hasNoSuchMethod(classElement)) {
return false;
}
ExecutableElement callMethod = _inheritanceManager.lookupMember(
@@ -5747,6 +5739,22 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
/**
+ * Return `true` if the given [classElement] has a noSuchMethod() method
+ * distinct from the one declared in class Object, as per the Dart Language
+ * Specification (section 10.4).
+ */
+ bool _hasNoSuchMethod(ClassElement classElement) {
+ MethodElement method = classElement.lookUpMethod(
+ FunctionElement.NO_SUCH_METHOD_METHOD_NAME, classElement.library);
+ if (method == null) {
+ return false;
+ }
+ ClassElement definingClass =
+ method.getAncestor((Element element) => element is ClassElement);
+ return definingClass != null && !definingClass.type.isObject;
+ }
+
+ /**
* Return `true` if the given [constructor] redirects to itself, directly or
* indirectly.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698