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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java

Issue 10831373: Issue 4543. Use complete Resolver before constants analyzer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
index 6df713b74c9f6612158af2557447966e539365f9..2691980e033b94d1d858a65aa039e8a0ca2c5874 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -9,7 +9,6 @@ import com.google.common.collect.Sets;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompilationPhase;
import com.google.dart.compiler.DartCompilerContext;
-import com.google.dart.compiler.InternalCompilerException;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartArrayLiteral;
import com.google.dart.compiler.ast.DartBinaryExpression;
@@ -420,13 +419,9 @@ public class CompileTimeConstantAnalyzer {
return null;
case NONE:
+ default:
expectedConstant(x);
return null;
-
- default:
- throw new InternalCompilerException("Unexpected element "
- + x.toString() + " kind: " + ElementKind.of(element)
- + " evaluating type for compile-time constant expression.");
}
return null;
}
@@ -490,6 +485,7 @@ public class CompileTimeConstantAnalyzer {
switch (ElementKind.of(x.getQualifier().getElement())) {
case CLASS:
case LIBRARY_PREFIX:
+ case LIBRARY:
case NONE:
// OK.
break;
@@ -633,10 +629,6 @@ public class CompileTimeConstantAnalyzer {
}
return null;
}
- if (isClassField && !isStatic) {
- DartExpression value = node.getValue();
- checkInstanceFieldInitializer(value);
- }
}
return super.visitField(node);
}
@@ -801,31 +793,4 @@ public class CompileTimeConstantAnalyzer {
public void exec(DartUnit unit) {
unit.accept(new FindCompileTimeConstantExpressionsVisitor());
}
-
- private void checkInstanceFieldInitializer(DartExpression value) {
- if (value != null) {
- value.accept(new ASTVisitor<Void>() {
- @Override
- public Void visitThisExpression(DartThisExpression node) {
- context.onError(new DartCompilationError(node,
- ResolverErrorCode.CANNOT_USE_THIS_IN_INSTANCE_FIELD_INITIALIZER));
- return null;
- }
- @Override
- public Void visitIdentifier(DartIdentifier node) {
- NodeElement element = node.getElement();
- if (ElementKind.of(element) == ElementKind.FIELD) {
- FieldElement fieldElement = (FieldElement) element;
- boolean isStatic = fieldElement.getModifiers().isStatic()
- || Elements.isTopLevel(fieldElement);
- if (!isStatic) {
- context.onError(new DartCompilationError(node,
- ResolverErrorCode.CANNOT_USE_INSTANCE_FIELD_IN_INSTANCE_FIELD_INITIALIZER));
- }
- }
- return null;
- }
- });
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698