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

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

Issue 46403004: Compile time error was removed for variable reference in its initializer. (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 f4fd89603a3ec9478b2e926ef7d1e9928dfeba9d..f1a9aa791ee21977e3ea0662d51d880d06d8384a 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
@@ -59,7 +59,6 @@ import com.google.dart.engine.ast.ImplementsClause;
import com.google.dart.engine.ast.ImportDirective;
import com.google.dart.engine.ast.IndexExpression;
import com.google.dart.engine.ast.InstanceCreationExpression;
-import com.google.dart.engine.ast.Label;
import com.google.dart.engine.ast.ListLiteral;
import com.google.dart.engine.ast.MapLiteral;
import com.google.dart.engine.ast.MapLiteralEntry;
@@ -926,7 +925,6 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
@Override
public Void visitSimpleIdentifier(SimpleIdentifier node) {
- checkForReferenceToDeclaredVariableInInitializer(node);
checkForImplicitThisReferenceInInitializer(node);
if (!isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) {
checkForUnqualifiedReferenceToNonLocalStaticMember(node);
@@ -4488,63 +4486,6 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
- * This checks if the passed identifier is banned because it is part of the variable declaration
- * with the same name.
- *
- * @param node the identifier to evaluate
- * @return {@code true} if and only if an error code is generated on the passed node
- * @see CompileTimeErrorCode#REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER
- */
- private boolean checkForReferenceToDeclaredVariableInInitializer(SimpleIdentifier node) {
- ASTNode parent = node.getParent();
- // ignore if property
- if (parent instanceof PrefixedIdentifier) {
- PrefixedIdentifier prefixedIdentifier = (PrefixedIdentifier) parent;
- if (prefixedIdentifier.getIdentifier() == node) {
- return false;
- }
- }
- if (parent instanceof PropertyAccess) {
- PropertyAccess propertyAccess = (PropertyAccess) parent;
- if (propertyAccess.getPropertyName() == node) {
- return false;
- }
- }
- // ignore if name of the method with target
- if (parent instanceof MethodInvocation) {
- MethodInvocation methodInvocation = (MethodInvocation) parent;
- if (methodInvocation.getTarget() != null && methodInvocation.getMethodName() == node) {
- return false;
- }
- }
- // ignore if name of the constructor
- if (parent instanceof ConstructorName) {
- ConstructorName constructorName = (ConstructorName) parent;
- if (constructorName.getName() == node) {
- return false;
- }
- }
- // ignore if name is a label
- if (parent instanceof Label) {
- Label label = (Label) parent;
- if (label.getLabel() == node) {
- return false;
- }
- }
- // check if name is banned
- String name = node.getName();
- if (!namesForReferenceToDeclaredVariableInInitializer.contains(name)) {
- return false;
- }
- // report problem
- errorReporter.reportError(
- CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER,
- node,
- name);
- return true;
- }
-
- /**
* This checks that the rethrow is inside of a catch clause.
*
* @param node the rethrow expression to evaluate

Powered by Google App Engine
This is Rietveld 408576698