Index: pkg/compiler/lib/src/compile_time_constants.dart |
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart |
index 71962e88957bcc163fdc0d7df455753022b6ab8c..bbabcf9f9aaf521a67cad7c5d96b3117f4471026 100644 |
--- a/pkg/compiler/lib/src/compile_time_constants.dart |
+++ b/pkg/compiler/lib/src/compile_time_constants.dart |
@@ -165,9 +165,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler { |
@override |
@deprecated |
ConstantValue getConstantValueForVariable(VariableElement element) { |
- ConstantExpression constant = initialVariableValues[element.declaration]; |
- // TODO(johnniwinther): Support eager evaluation of the constant. |
- return constant != null ? getConstantValue(constant) : null; |
+ return getConstantValue(initialVariableValues[element.declaration]); |
} |
ConstantExpression compileConstant(VariableElement element) { |
@@ -322,27 +320,8 @@ abstract class ConstantCompilerBase implements ConstantCompiler { |
return constantValueMap.containsKey(expression); |
} |
- @override |
ConstantValue getConstantValue(ConstantExpression expression) { |
- assert(invariant(CURRENT_ELEMENT_SPANNABLE, expression != null, |
- message: "ConstantExpression is null in getConstantValue.")); |
- // TODO(johnniwinther): ensure expressions have been evaluated at this |
- // point. This can't be enabled today due to dartbug.com/26406. |
- if (compiler.serialization.supportsDeserialization) { |
- evaluate(expression); |
- } |
- ConstantValue value = constantValueMap[expression]; |
- if (value == null && |
- expression != null && |
- expression.kind == ConstantExpressionKind.ERRONEOUS) { |
- // TODO(johnniwinther): When the Dart constant system sees a constant |
- // expression as erroneous but the JavaScript constant system finds it ok |
- // we have store a constant value for the erroneous constant expression. |
- // Ensure the computed constant expressions are always the same; that only |
- // the constant values may be different. |
- value = new NullConstantValue(); |
- } |
- return value; |
+ return constantValueMap[expression]; |
} |
ConstantExpression compileNode(Node node, TreeElements elements, |
@@ -380,7 +359,7 @@ class DartConstantCompiler extends ConstantCompilerBase { |
Node node, TreeElements definitions, |
{bool isConst: true}) { |
ConstantExpression constant = definitions.getConstant(node); |
- if (constant != null && hasConstantValue(constant)) { |
+ if (constant != null && getConstantValue(constant) != null) { |
return constant; |
} |
constant = |