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

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

Issue 9921015: Visit name of DartDeclaration, set Element for DartIdentifier (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Visit more name-like nodes, tweaks for review Created 8 years, 9 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 5a2583cb7db9a8b110227403af88beb24a42aa5a..c6e0651fc0465b88f422fb0b35e6e02825c2a428 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -14,6 +14,7 @@ import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartArrayLiteral;
import com.google.dart.compiler.ast.DartBinaryExpression;
import com.google.dart.compiler.ast.DartBooleanLiteral;
+import com.google.dart.compiler.ast.DartDeclaration;
import com.google.dart.compiler.ast.DartDoubleLiteral;
import com.google.dart.compiler.ast.DartExpression;
import com.google.dart.compiler.ast.DartField;
@@ -310,6 +311,11 @@ public class CompileTimeConstantAnalyzer {
public Void visitIdentifier(DartIdentifier x) {
x.visitChildren(this);
+ if (x.getParent() instanceof DartDeclaration<?>
+ && ((DartDeclaration<?>) x.getParent()).getName() == x) {
+ return null;
+ }
+
Element element = x.getElement();
switch (ElementKind.of(element)) {
case CLASS:
@@ -337,9 +343,9 @@ public class CompileTimeConstantAnalyzer {
final Type inferredType;
if (element instanceof FieldNodeElement) {
FieldNodeElement fieldNodeElement = (FieldNodeElement) element;
- DartNode identifierNode = fieldNodeElement.getNode();
- identifierNode.accept(this);
- inferredType = getMostSpecificType(identifierNode);
+ DartNode fieldNode = fieldNodeElement.getNode();
+ fieldNode.accept(this);
+ inferredType = getMostSpecificType(fieldNode);
fieldNodeElement.setConstantType(inferredType);
} else if (fieldElement.getType() != null
&& !fieldElement.getType().equals(dynamicType)) {

Powered by Google App Engine
This is Rietveld 408576698