| Index: pkg/compiler/lib/src/deferred_load.dart
|
| diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
|
| index 6141447892f5802c8efe4f4af2bbd0affa5ab5a7..bbd91aef1d444f74a372b1eb27c0c2bb922ef55b 100644
|
| --- a/pkg/compiler/lib/src/deferred_load.dart
|
| +++ b/pkg/compiler/lib/src/deferred_load.dart
|
| @@ -336,16 +336,28 @@ class DeferredLoadTask extends CompilerTask {
|
| TreeElements treeElements = analyzableElement.resolvedAst.elements;
|
| assert(treeElements != null);
|
|
|
| + // TODO(johnniwinther): Add only expressions that are actually needed.
|
| + // Currently we have some noise here: Some potential expressions are
|
| + // seen that should never be added (for instance field initializers
|
| + // in constant constructors, like `this.field = parameter`). And some
|
| + // implicit constant expression are seen that we should be able to add
|
| + // (like primitive constant literals like `true`, `"foo"` and `0`).
|
| + // See dartbug.com/26406 for context.
|
| treeElements
|
| .forEachConstantNode((Node node, ConstantExpression expression) {
|
| // Explicitly depend on the backend constants.
|
| - ConstantValue value;
|
| - value = backend.constants.getConstantValue(expression);
|
| - // TODO(johnniwinther): ensure `value` is not null or use directly the
|
| - // expression to calculate dependencies. See dartbug.com/26406 for
|
| - // context.
|
| - if (value != null) {
|
| + if (backend.constants.hasConstantValue(expression)) {
|
| + ConstantValue value =
|
| + backend.constants.getConstantValue(expression);
|
| + assert(invariant(node, value != null,
|
| + message: "Constant expression without value: "
|
| + "${expression.toStructuredText()}."));
|
| constants.add(value);
|
| + } else {
|
| + assert(invariant(node,
|
| + expression.isImplicit || expression.isPotential,
|
| + message: "Unexpected unevaluated constant expression: "
|
| + "${expression.toStructuredText()}."));
|
| }
|
| });
|
| }
|
|
|