Index: pkg/compiler/lib/src/serialization/modelz.dart |
diff --git a/pkg/compiler/lib/src/serialization/modelz.dart b/pkg/compiler/lib/src/serialization/modelz.dart |
index 9c346d935b83634ea20b720211b4d32fdf090881..b7f17b3bf7de73ba1457c12e9c696cd98c8f4f76 100644 |
--- a/pkg/compiler/lib/src/serialization/modelz.dart |
+++ b/pkg/compiler/lib/src/serialization/modelz.dart |
@@ -1271,6 +1271,7 @@ abstract class FieldElementZ extends DeserializedElementZ |
TypedElementMixin, |
MemberElementMixin |
implements FieldElement { |
+ bool _isConst; |
ConstantExpression _constant; |
FieldElementZ(ObjectDecoder decoder) : super(decoder); |
@@ -1286,14 +1287,22 @@ abstract class FieldElementZ extends DeserializedElementZ |
@override |
bool get isFinal => _decoder.getBool(Key.IS_FINAL); |
+ void _ensureConstant() { |
+ if (_isConst == null) { |
+ _isConst = _decoder.getBool(Key.IS_CONST); |
+ _constant = _decoder.getConstant(Key.CONSTANT, isOptional: true); |
+ } |
+ } |
+ |
@override |
- bool get isConst => _decoder.getBool(Key.IS_CONST); |
+ bool get isConst { |
+ _ensureConstant(); |
+ return _isConst; |
+ } |
@override |
ConstantExpression get constant { |
- if (isConst && _constant == null) { |
- _constant = _decoder.getConstant(Key.CONSTANT); |
- } |
+ _ensureConstant(); |
return _constant; |
} |