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

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

Issue 10919290: Issue 3476. Final variables don't have to have constant initializers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fa16775977e64ef93b2f98b2b4d729f015dbcbb8..4ed2b47e0d45bf3c47aee5250cd0a2de0c770694 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -411,7 +411,7 @@ public class CompileTimeConstantAnalyzer {
break;
case VARIABLE:
- if (!element.getModifiers().isConstant() && !element.getModifiers().isFinal()) {
+ if (!element.getModifiers().isConstant()) {
expectedConstant(x);
}
return null;
@@ -508,9 +508,7 @@ public class CompileTimeConstantAnalyzer {
return null;
}
// OK. Constant field.
- // TODO(brianwilkerson) Remove the second condition when final variables are no longer
- // treated like constants
- if (element.getModifiers().isConstant() || element.getModifiers().isFinal()) {
+ if (element.getModifiers().isConstant()) {
return null;
}
// Fail.
@@ -623,12 +621,7 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitField(DartField node) {
if (node.getParent() != null) {
- DartNode pp = node.getParent().getParent();
- boolean isFinalTopLevelField = node.getModifiers().isFinal() && pp instanceof DartUnit;
- boolean isClassField = pp instanceof DartClass;
- boolean isStatic = node.getModifiers().isStatic();
- boolean isConst = node.getModifiers().isConstant();
- if (isFinalTopLevelField || (isClassField && isStatic) || isConst) {
+ if (node.getModifiers().isConstant()) {
Type type = checkConstantExpression(node.getValue());
if (node.getElement().getType().equals(dynamicType)) {
node.getElement().setConstantType(type);
@@ -725,7 +718,7 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitVariableStatement(DartVariableStatement node) {
Modifiers modifiers = node.getModifiers();
- if (modifiers.isConstant() || (modifiers.isStatic() && modifiers.isFinal())) {
+ if (modifiers.isConstant()) {
for (DartVariable variable : node.getVariables()) {
if (variable.getValue() != null) {
checkConstantExpression(variable.getValue());
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698