Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2015053002: Resynthesize constant field initializers lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 27a963dcc322d85b50677c39f39af282c73e5781..e34bcb9a9b2e07e43adb0ea2de17ce4e694af114 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1571,6 +1571,25 @@ class ConstFieldElementImpl extends FieldElementImpl with ConstVariableElement {
ConstFieldElementImpl.forSerialized(
UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement)
: super.forSerialized(unlinkedVariable, enclosingElement);
+
+ @override
+ Expression get constantInitializer {
+ if (_unlinkedVariable != null) {
+ UnlinkedConst defaultValue = _unlinkedVariable.initializer?.bodyExpr;
+ if (defaultValue == null) {
+ return null;
+ }
+ return super.constantInitializer ??= enclosingUnit.resynthesizerContext
+ .buildExpression(this, defaultValue);
+ }
+ return super.constantInitializer;
+ }
+
+ @override
+ void set constantInitializer(Expression initializer) {
+ assert(_unlinkedVariable == null);
+ super.constantInitializer = initializer;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698