| Index: frog/leg/compile_time_constants.dart
|
| diff --git a/frog/leg/compile_time_constants.dart b/frog/leg/compile_time_constants.dart
|
| index 0d7f07d5e869fad06098f9036787dcbffa196064..bb3f67cedad55bca0fe1bd30f5ff9a2d9df2e4de 100644
|
| --- a/frog/leg/compile_time_constants.dart
|
| +++ b/frog/leg/compile_time_constants.dart
|
| @@ -453,14 +453,18 @@ class ConstructedConstant extends ObjectConstant {
|
| class ConstantHandler extends CompilerTask {
|
| // Contains the initial value of fields. Must contain all static and global
|
| // initializations of used fields. May contain caches for instance fields.
|
| - final Map<VariableElement, Dynamic> initialVariableValues;
|
| + final Map<VariableElement, Constant> initialVariableValues;
|
|
|
| // Map from compile-time constants to their JS name.
|
| final Map<Constant, String> compiledConstants;
|
|
|
| + // The set of variable elements that are in the process of being computed.
|
| + final Set<VariableElement> pendingVariables;
|
| +
|
| ConstantHandler(Compiler compiler)
|
| : initialVariableValues = new Map<VariableElement, Dynamic>(),
|
| compiledConstants = new Map<Constant, String>(),
|
| + pendingVariables = new Set<Constant>(),
|
| super(compiler);
|
| String get name() => 'ConstantHandler';
|
|
|
| @@ -483,6 +487,7 @@ class ConstantHandler extends CompilerTask {
|
| // Shortcut if it has already been compiled.
|
| if (initialVariableValues.containsKey(element)) return;
|
| compileVariableWithDefinitions(element, work.resolutionTree);
|
| + assert(pendingVariables.isEmpty());
|
| }
|
|
|
| compileVariable(VariableElement element) {
|
| @@ -508,10 +513,19 @@ class ConstantHandler extends CompilerTask {
|
| // No initial value.
|
| value = new NullConstant();
|
| } else {
|
| + if (pendingVariables.contains(element)) {
|
| + MessageKind kind = MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS;
|
| + compiler.reportError(node,
|
| + new CompileTimeConstantError(kind, const []));
|
| + }
|
| + pendingVariables.add(element);
|
| +
|
| Node right = assignment.arguments.head;
|
| CompileTimeConstantEvaluator evaluator =
|
| new CompileTimeConstantEvaluator(this, definitions, compiler);
|
| value = evaluator.evaluate(right);
|
| +
|
| + pendingVariables.remove(element);
|
| }
|
| initialVariableValues[element] = value;
|
| return value;
|
|
|