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

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

Issue 15271006: Report DUPLICATE_CONSTRUCTOR_NAME and other scope fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert most changes and mark tests invalid. 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/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 9db388c3184781527d5b63a19a5eafc6cc5f9799..8816057a4e03a254048165be6bf014d5f8bcaf3c 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
@@ -113,6 +113,7 @@ import com.google.dart.engine.type.InterfaceType;
import com.google.dart.engine.type.Type;
import com.google.dart.engine.type.TypeVariableType;
import com.google.dart.engine.utilities.dart.ParameterKind;
+import com.google.dart.engine.utilities.general.ObjectUtilities;
import java.util.HashMap;
import java.util.HashSet;
@@ -1362,9 +1363,26 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
private boolean checkForConflictingConstructorNameAndMember(ConstructorDeclaration node) {
ConstructorElement constructorElement = node.getElement();
SimpleIdentifier constructorName = node.getName();
+ String name = constructorElement.getName();
+ ClassElement classElement = constructorElement.getEnclosingElement();
+ // constructors
+ ConstructorElement[] constructors = classElement.getConstructors();
+ for (ConstructorElement otherConstructor : constructors) {
+ if (otherConstructor == constructorElement) {
+ continue;
+ }
+ if (ObjectUtilities.equals(name, otherConstructor.getName())) {
+ if (name == null || name.length() == 0) {
+ errorReporter.reportError(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, node);
+ } else {
+ errorReporter.reportError(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, node, name);
+ }
+ return true;
+ }
+ }
+ // conflict with class member
if (constructorName != null && constructorElement != null && !constructorName.isSynthetic()) {
- String name = constructorName.getName();
- ClassElement classElement = constructorElement.getEnclosingElement();
+ // fields
FieldElement[] fields = classElement.getFields();
for (FieldElement field : fields) {
if (field.getName().equals(name)) {
@@ -1375,6 +1393,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
return true;
}
}
+ // methods
MethodElement[] methods = classElement.getMethods();
for (MethodElement method : methods) {
if (method.getName().equals(name)) {

Powered by Google App Engine
This is Rietveld 408576698