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..695f33e6b022e8f58baf91fe4689c1a7e00f7540 100644 |
--- a/pkg/compiler/lib/src/deferred_load.dart |
+++ b/pkg/compiler/lib/src/deferred_load.dart |
@@ -336,16 +336,25 @@ class DeferredLoadTask extends CompilerTask { |
TreeElements treeElements = analyzableElement.resolvedAst.elements; |
assert(treeElements != null); |
+ // TODO(johnniwinther): Add only expressions that are actually needed. |
+ // Currently some potential expressions are visited that should never |
+ // be added, and some implicit constant expression that should be |
Siggi Cherem (dart-lang)
2016/05/09 20:03:04
rephrase? (I'm not sure I understood the last phra
Johnni Winther
2016/05/10 09:26:16
Done.
|
+ // allowed. 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()}.")); |
} |
}); |
} |