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

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

Issue 27055004: Issue 13703. Report CONFLICTING_TYPE_VARIABLE_AND_CLASS and CONFLICTING_TYPE_VARIABLE_AND_MEMBER. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 587e5876114ffae4cebded483af59428b6bdb6b3..16a41859bdc4b75883ef9e3287f36925221812d4 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
@@ -432,6 +432,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
checkForMemberWithClassName();
checkForNoDefaultSuperConstructorImplicit(node);
checkForAllMixinErrorCodes(withClause);
+ checkForConflictingTypeVariableErrorCodes(node);
if (implementsClause != null || extendsClause != null) {
if (!checkForImplementsDisallowedClass(implementsClause)
&& !checkForExtendsDisallowedClass(extendsClause)) {
@@ -2280,6 +2281,41 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies all conflicts between type variable and enclosing class. TODO(scheglov)
+ *
+ * @param node the class declaration to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#CONFLICTING_TYPE_VARIABLE_AND_CLASS
+ * @see CompileTimeErrorCode#CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ */
+ private boolean checkForConflictingTypeVariableErrorCodes(ClassDeclaration node) {
+ boolean problemReported = false;
+ for (TypeParameterElement typeParameter : enclosingClass.getTypeParameters()) {
+ String name = typeParameter.getName();
+ // name is same as the name of the enclosing class
+ if (enclosingClass.getName().equals(name)) {
+ errorReporter.reportError(
+ CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS,
+ typeParameter.getNameOffset(),
+ name.length(),
+ name);
+ problemReported = true;
+ }
+ // check members
+ if (enclosingClass.getMethod(name) != null || enclosingClass.getGetter(name) != null
+ || enclosingClass.getSetter(name) != null) {
+ errorReporter.reportError(
+ CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER,
+ typeParameter.getNameOffset(),
+ name.length(),
+ name);
+ problemReported = true;
+ }
+ }
+ return problemReported;
+ }
+
+ /**
* This verifies that if the passed constructor declaration is 'const' then there are no
* invocations of non-'const' super constructors.
*

Powered by Google App Engine
This is Rietveld 408576698