| 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.
|
| *
|
|
|