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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1701413005: Fix for making variable initializer synthetic. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 7929548678e3444db9ee3160f6740e156208dc87..be97bfb0d091b1169d926c789a362dbf04581183 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1466,7 +1466,8 @@ class _LibraryResynthesizer {
/**
* Resynthesize a local [FunctionElement].
*/
- FunctionElement buildLocalFunction(UnlinkedExecutable serializedExecutable) {
+ FunctionElementImpl buildLocalFunction(
+ UnlinkedExecutable serializedExecutable) {
FunctionElementImpl element = new FunctionElementImpl(
serializedExecutable.name, serializedExecutable.nameOffset);
if (serializedExecutable.visibleOffset != 0) {
@@ -1563,10 +1564,7 @@ class _LibraryResynthesizer {
}
parameterElement.hasImplicitType = serializedParameter.type == null;
}
- if (serializedParameter.initializer != null) {
- parameterElement.initializer =
- buildLocalFunction(serializedParameter.initializer);
- }
+ buildVariableInitializer(parameterElement, serializedParameter.initializer);
switch (serializedParameter.kind) {
case UnlinkedParamKind.named:
parameterElement.parameterKind = ParameterKind.NAMED;
@@ -1750,14 +1748,27 @@ class _LibraryResynthesizer {
element.const3 = serializedVariable.isConst;
element.final2 = serializedVariable.isFinal;
element.hasImplicitType = serializedVariable.type == null;
- if (serializedVariable.initializer != null) {
- element.initializer = buildLocalFunction(serializedVariable.initializer);
- }
+ buildVariableInitializer(element, serializedVariable.initializer);
buildDocumentation(element, serializedVariable.documentationComment);
buildAnnotations(element, serializedVariable.annotations);
}
/**
+ * If the given [serializedInitializer] is not `null`, create the
+ * corresponding [FunctionElementImpl] and set it for the [variable].
+ */
+ void buildVariableInitializer(
+ VariableElementImpl variable, UnlinkedExecutable serializedInitializer) {
+ if (serializedInitializer == null) {
+ return null;
+ }
+ FunctionElementImpl initializerElement =
+ buildLocalFunction(serializedInitializer);
+ initializerElement.synthetic = true;
+ variable.initializer = initializerElement;
+ }
+
+ /**
* Finish creating a [TypeParameterElement] by deserializing its bound.
*/
void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter,
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698