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

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

Issue 9728006: Some compile time constants were not properly reporting static type warnings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 53cf856b65d43f69927e4089c72824782ee3bd9d..a57418f8dd9d9d0f54af561be7fbe69badd37f8c 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -46,6 +46,7 @@ import com.google.dart.compiler.ast.DartVariableStatement;
import com.google.dart.compiler.ast.Modifiers;
import com.google.dart.compiler.common.HasSourceInfo;
import com.google.dart.compiler.type.Type;
+import com.google.dart.compiler.type.Types;
import java.util.List;
import java.util.Map;
@@ -321,6 +322,9 @@ public class CompileTimeConstantAnalyzer {
identifierNode.accept(this);
inferredType = getMostSpecificType(identifierNode);
fieldNodeElement.setConstantType(inferredType);
+ } else if (fieldElement.getType() != null
+ && !fieldElement.getType().equals(dynamicType)) {
+ inferredType = fieldElement.getType();
} else {
inferredType = fieldElement.getConstantType();
}
@@ -506,7 +510,9 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitField(DartField node) {
Type type = checkConstantExpression(node.getValue());
- node.getElement().setConstantType(type);
+ if (node.getElement().getType().equals(dynamicType)) {
+ node.getElement().setConstantType(type);
+ }
return null;
}

Powered by Google App Engine
This is Rietveld 408576698