| Index: lib/compiler/implementation/compile_time_constants.dart
|
| ===================================================================
|
| --- lib/compiler/implementation/compile_time_constants.dart (revision 12037)
|
| +++ lib/compiler/implementation/compile_time_constants.dart (working copy)
|
| @@ -125,11 +125,24 @@
|
| Node right = assignment.arguments.head;
|
| value =
|
| compileNodeWithDefinitions(right, definitions, isConst: isConst);
|
| + if (compiler.enableTypeAssertions
|
| + && value != null
|
| + && element.isField()) {
|
| + DartType elementType = element.computeType(compiler);
|
| + DartType constantType = value.computeType(compiler);
|
| + if (!compiler.types.isSubtype(constantType, elementType)) {
|
| + // If the type of the constant does not implement the
|
| + // declared type of the variable, we make the initialization
|
| + // of this variable lazy so that at runtime we get the type
|
| + // error only if the variable is used.
|
| + value = null;
|
| + }
|
| + }
|
| }
|
| if (value != null) {
|
| initialVariableValues[element] = value;
|
| } else {
|
| - assert(!isConst);
|
| + assert(!isConst || compiler.enableTypeAssertions);
|
| lazyStatics.add(element);
|
| }
|
| pendingVariables.remove(element);
|
| @@ -273,8 +286,8 @@
|
| link = link.tail) {
|
| arguments.add(evaluateConstant(link.head));
|
| }
|
| - // TODO(floitsch): get type from somewhere.
|
| - DartType type = null;
|
| + // TODO(floitsch): get type parameters.
|
| + DartType type = new InterfaceType(compiler.listClass);
|
| Constant constant = new ListConstant(type, arguments);
|
| compiler.constantHandler.registerCompileTimeConstant(constant);
|
| return constant;
|
| @@ -311,7 +324,7 @@
|
| }
|
| bool hasProtoKey = (protoValue !== null);
|
| // TODO(floitsch): this should be a List<String> type.
|
| - DartType keysType = null;
|
| + DartType keysType = new InterfaceType(compiler.listClass);
|
| ListConstant keysList = new ListConstant(keysType, keys);
|
| compiler.constantHandler.registerCompileTimeConstant(keysList);
|
| SourceString className = hasProtoKey
|
|
|