| 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 fd7ad6e3b7bf2b2150a60c9d9b37a6df8a6e2fbf..5357e9a377c1ec21157369058839a94af124abf3 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
|
| @@ -255,6 +255,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| checkForBuiltInIdentifierAsName(
|
| node.getName(),
|
| CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME);
|
| + checkForMemberWithClassName();
|
| // initialize initialFieldElementsMap
|
| ClassElement classElement = node.getElement();
|
| if (classElement != null) {
|
| @@ -1414,6 +1415,37 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This verifies that the {@link #enclosingClass} does not define members with the same name as
|
| + * the enclosing class.
|
| + *
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#MEMBER_WITH_CLASS_NAME
|
| + */
|
| + private boolean checkForMemberWithClassName() {
|
| + if (enclosingClass == null) {
|
| + return false;
|
| + }
|
| + String className = enclosingClass.getName();
|
| + if (className == null) {
|
| + return false;
|
| + }
|
| + boolean problemReported = false;
|
| + // check accessors
|
| + for (PropertyAccessorElement accessor : enclosingClass.getAccessors()) {
|
| + if (className.equals(accessor.getName())) {
|
| + errorReporter.reportError(
|
| + CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME,
|
| + accessor.getNameOffset(),
|
| + className.length());
|
| + problemReported = true;
|
| + }
|
| + }
|
| + // don't check methods, they would be constructors
|
| + // done
|
| + return problemReported;
|
| + }
|
| +
|
| + /**
|
| * Checks to ensure that native function bodies can only in SDK code.
|
| *
|
| * @param node the native function body to test
|
|
|