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 82cc6de475a33f0a2bab749c9271307236783804..b476d9c15ec6c2348ac247f6247223b7df00e4f1 100644 |
--- a/pkg/compiler/lib/src/compile_time_constants.dart |
+++ b/pkg/compiler/lib/src/compile_time_constants.dart |
@@ -16,7 +16,7 @@ import 'constants/values.dart'; |
import 'core_types.dart' show CoreTypes; |
import 'dart_types.dart'; |
import 'elements/elements.dart'; |
-import 'elements/modelx.dart' show FieldElementX, FunctionElementX; |
+import 'elements/modelx.dart' show FieldElementX, FunctionElementX, ConstantVariableMixin; |
import 'resolution/tree_elements.dart' show TreeElements; |
import 'resolution/operators.dart'; |
import 'tree/tree.dart'; |
@@ -187,8 +187,14 @@ abstract class ConstantCompilerBase implements ConstantCompiler { |
ConstantExpression result = initialVariableValues[element.declaration]; |
return result; |
} |
+ if (element.hasConstant) { |
+ if (element.constant != null) { |
+ evaluate(element.constant); |
Siggi Cherem (dart-lang)
2016/05/19 16:46:45
could this add more evaluations than what we had i
Johnni Winther
2016/05/20 11:02:13
I'll put it behind a test for deserialization.
Siggi Cherem (dart-lang)
2016/05/20 21:08:02
Not sure I follow why it is needed then. I would e
Johnni Winther
2016/05/23 07:54:41
Yes. Will add an assertion.
|
+ } |
+ return element.constant; |
+ } |
AstElement currentElement = element.analyzableElement; |
- return reporter.withCurrentElement(currentElement, () { |
+ return reporter.withCurrentElement(element, () { |
// TODO(johnniwinther): Avoid this eager analysis. |
compiler.resolution.ensureResolved(currentElement.declaration); |
@@ -206,7 +212,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler { |
* error. |
*/ |
ConstantExpression compileVariableWithDefinitions( |
- VariableElement element, TreeElements definitions, |
+ ConstantVariableMixin element, TreeElements definitions, |
{bool isConst: false, bool checkType: true}) { |
Node node = element.node; |
if (pendingVariables.contains(element)) { |
@@ -262,6 +268,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler { |
} |
} |
if (expression != null) { |
+ element.constant = expression; |
initialVariableValues[element.declaration] = expression; |
} else { |
assert(invariant(element, !isConst, |
@@ -1280,13 +1287,12 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator { |
Map<FieldElement, AstConstant> fieldConstants = |
<FieldElement, AstConstant>{}; |
classElement.implementation.forEachInstanceField( |
- (ClassElement enclosing, FieldElementX field) { |
+ (ClassElement enclosing, FieldElement field) { |
AstConstant fieldValue = fieldValues[field]; |
if (fieldValue == null) { |
// Use the default value. |
ConstantExpression fieldExpression = |
handler.internalCompileVariable(field, true, false); |
- field.constant = fieldExpression; |
fieldValue = new AstConstant.fromDefaultValue( |
field, fieldExpression, handler.getConstantValue(fieldExpression)); |
// TODO(het): If the field value doesn't typecheck due to the type |