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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 29283003: Fix issue 12654 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 7 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
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 550d1d689484260e777aef4b7ad233a750cf2b47..e65288de83fc0e0d2b72595b7be800d26ac441eb 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
@@ -457,6 +457,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
checkForDuplicateDefinitionInheritance();
checkForConflictingGetterAndMethod();
checkImplementsSuperClass(node);
+ checkImplementsFunctionWithoutCall(node);
return super.visitClassDeclaration(node);
} finally {
isInNativeClass = false;
@@ -4892,6 +4893,33 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies that if the given class declaration implements the class Function that it has a
+ * concrete implementation of the call method.
+ *
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see StaticWarningCode#FUNCTION_WITHOUT_CALL
+ */
+ private boolean checkImplementsFunctionWithoutCall(ClassDeclaration node) {
+ if (node.getAbstractKeyword() != null) {
+ return false;
+ }
+ ClassElement classElement = node.getElement();
+ if (classElement == null) {
+ return false;
+ }
+ if (!classElement.getType().isSubtypeOf(typeProvider.getFunctionType())) {
+ return false;
+ }
+ ExecutableElement callMethod = inheritanceManager.lookupMember(classElement, "call");
+ if (callMethod == null || !(callMethod instanceof MethodElement)
+ || ((MethodElement) callMethod).isAbstract()) {
+ errorReporter.reportError(StaticWarningCode.FUNCTION_WITHOUT_CALL, node.getName());
+ return true;
+ }
+ return false;
+ }
+
+ /**
* This verifies that the given class declaration does not have the same class in the 'extends'
* and 'implements' clauses.
*

Powered by Google App Engine
This is Rietveld 408576698