File tree 4 files changed +11
-9
lines changed 4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -1450,8 +1450,7 @@ class DeferredConstantExpression extends ConstantExpression {
1450
1450
ConstantValue evaluate (
1451
1451
Environment environment, ConstantSystem constantSystem) {
1452
1452
return new DeferredConstantValue (
1453
- expression.evaluate (environment, constantSystem),
1454
- prefix);
1453
+ expression.evaluate (environment, constantSystem), prefix);
1455
1454
}
1456
1455
1457
1456
@override
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ class NullConstantValue extends PrimitiveConstantValue {
159
159
/** The value a Dart null is compiled to in JavaScript. */
160
160
static const String JsNull = "null" ;
161
161
162
- factory NullConstantValue () => const NullConstantValue ._internal () ;
162
+ const factory NullConstantValue () = NullConstantValue ._internal;
163
163
164
164
const NullConstantValue ._internal ();
165
165
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ import 'common/tasks.dart' show CompilerTask;
9
9
import 'common.dart' ;
10
10
import 'compiler.dart' show Compiler;
11
11
import 'constants/expressions.dart'
12
- show
13
- ConstantExpression,
14
- ConstantExpressionKind;
12
+ show ConstantExpression, ConstantExpressionKind;
15
13
import 'constants/values.dart'
16
14
show
17
15
ConstantValue,
@@ -338,12 +336,13 @@ class DeferredLoadTask extends CompilerTask {
338
336
TreeElements treeElements = analyzableElement.resolvedAst.elements;
339
337
assert (treeElements != null );
340
338
341
- treeElements. forEachConstantNode (
342
- (Node node, ConstantExpression expression) {
339
+ treeElements
340
+ . forEachConstantNode ( (Node node, ConstantExpression expression) {
343
341
// Explicitly depend on the backend constants.
344
342
ConstantValue value = backend.constants.getConstantValue (expression);
345
343
assert (invariant (node, value != null ,
346
- message: "No constant value for ${expression .toStructuredText ()}." ));
344
+ message:
345
+ "No constant value for ${expression .toStructuredText ()}." ));
347
346
constants.add (value);
348
347
});
349
348
}
Original file line number Diff line number Diff line change @@ -198,6 +198,10 @@ class HGraph {
198
198
HConstant result = constants[constant];
199
199
// TODO(johnniwinther): Support source information per constant reference.
200
200
if (result == null ) {
201
+ if (! constant.isConstant) {
202
+ // We use `null` as the value for invalid constant expressions.
203
+ constant = const NullConstantValue ();
204
+ }
201
205
TypeMask type = computeTypeMask (compiler, constant);
202
206
result = new HConstant .internal (constant, type)
203
207
..sourceInformation = sourceInformation;
You can’t perform that action at this time.
0 commit comments