Index: pkg/compiler/lib/src/js_backend/backend.dart |
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart |
index 7489914a3e70deba3fcc2a864191e4b5d8aba83d..cbae71286b2011c603c27cd6c4d8b2aa968c2841 100644 |
--- a/pkg/compiler/lib/src/js_backend/backend.dart |
+++ b/pkg/compiler/lib/src/js_backend/backend.dart |
@@ -1527,17 +1527,24 @@ class JavaScriptBackend extends Backend { |
ConstantExpression constant = variableElement.constant; |
if (constant != null) { |
ConstantValue initialValue = constants.getConstantValue(constant); |
- assert(invariant(variableElement, initialValue != null, |
- message: "Constant expression without value: " |
- "${constant.toStructuredText()}.")); |
- registerCompileTimeConstant(initialValue, work.registry); |
- addCompileTimeConstantForEmission(initialValue); |
- // We don't need to generate code for static or top-level |
- // variables. For instance variables, we may need to generate |
- // the checked setter. |
- if (Elements.isStaticOrTopLevel(element)) { |
- return impactTransformer |
- .transformCodegenImpact(work.registry.worldImpact); |
+ if (initialValue != null) { |
+ registerCompileTimeConstant(initialValue, work.registry); |
+ addCompileTimeConstantForEmission(initialValue); |
+ // We don't need to generate code for static or top-level |
+ // variables. For instance variables, we may need to generate |
+ // the checked setter. |
+ if (Elements.isStaticOrTopLevel(element)) { |
+ return impactTransformer |
+ .transformCodegenImpact(work.registry.worldImpact); |
+ } |
+ } else { |
+ assert(invariant( |
+ variableElement, |
+ variableElement.isInstanceMember || |
+ constant.isImplicit || |
+ constant.isPotential, |
+ message: "Constant expression without value: " |
+ "${constant.toStructuredText()}.")); |
} |
} else { |
// If the constant-handler was not able to produce a result we have to |