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

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

Issue 15083002: Report CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/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 00c9a626575bacb3a07a8a69b99d788b13f3ec4d..5532cd276ca8f762f5b727c8f61b951270f69d37 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
@@ -22,6 +22,7 @@ import com.google.dart.engine.ast.BinaryExpression;
import com.google.dart.engine.ast.BreakStatement;
import com.google.dart.engine.ast.Combinator;
import com.google.dart.engine.ast.CommentReference;
+import com.google.dart.engine.ast.ConstructorDeclaration;
import com.google.dart.engine.ast.ConstructorFieldInitializer;
import com.google.dart.engine.ast.ConstructorName;
import com.google.dart.engine.ast.ContinueStatement;
@@ -200,6 +201,18 @@ public class ElementResolver extends SimpleASTVisitor<Void> {
}
/**
+ * @return {@code true} if the given identifier is the return type of a constructor declaration.
+ */
+ private static boolean isConstructorReturnType(SimpleIdentifier node) {
+ ASTNode parent = node.getParent();
+ if (parent instanceof ConstructorDeclaration) {
+ ConstructorDeclaration constructor = (ConstructorDeclaration) parent;
+ return constructor.getReturnType() == node;
+ }
+ return false;
+ }
+
+ /**
* The resolver driving this participant.
*/
private ResolverVisitor resolver;
@@ -829,7 +842,9 @@ public class ElementResolver extends SimpleASTVisitor<Void> {
}
if (element == null) {
// TODO(brianwilkerson) Recover from this error.
- if (!classDeclaresNoSuchMethod(enclosingClass)) {
+ if (isConstructorReturnType(node)) {
+ resolver.reportError(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node);
+ } else if (!classDeclaresNoSuchMethod(enclosingClass)) {
resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, node.getName());
}
} else if (element instanceof ExecutableElement) {

Powered by Google App Engine
This is Rietveld 408576698