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

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

Issue 1597893003: Don't include implicit initializing formal types in summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/summarize_elements.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 993de5334cc68a80879836613146fba0d17341a8..33f66ae475cfb84319f36f93e46943a0b377bbb9 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -267,6 +267,13 @@ class _LibraryResynthesizer {
*/
List<TypeParameterElement> currentTypeParameters = <TypeParameterElement>[];
+ /**
+ * If a class is currently being resynthesized, map from field name to the
+ * type of the corresponding field. This is used to populate the types of
+ * initializing formal parameters whose type is implicit.
+ */
+ Map<String, DartType> fieldTypes;
+
_LibraryResynthesizer(this.summaryResynthesizer, this.linkedLibrary,
this.unlinkedUnits, this.librarySource) {
isCoreLibrary = librarySource.uri.toString() == 'dart:core';
@@ -308,6 +315,10 @@ class _LibraryResynthesizer {
classElement.mixins = serializedClass.mixins.map(buildType).toList();
classElement.typeParameters = currentTypeParameters;
ElementHolder memberHolder = new ElementHolder();
+ fieldTypes = <String, DartType>{};
+ for (UnlinkedVariable serializedVariable in serializedClass.fields) {
+ buildVariable(serializedVariable, memberHolder);
+ }
bool constructorFound = false;
for (UnlinkedExecutable serializedExecutable
in serializedClass.executables) {
@@ -324,9 +335,6 @@ class _LibraryResynthesizer {
break;
}
}
- for (UnlinkedVariable serializedVariable in serializedClass.fields) {
- buildVariable(serializedVariable, memberHolder);
- }
if (!serializedClass.isMixinApplication) {
if (!constructorFound) {
// Synthesize implicit constructors.
@@ -349,6 +357,7 @@ class _LibraryResynthesizer {
unitHolder.addType(classElement);
} finally {
currentTypeParameters = <TypeParameterElement>[];
+ fieldTypes = null;
}
}
@@ -854,7 +863,14 @@ class _LibraryResynthesizer {
parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
parameterTypeElement, null, currentTypeArguments, false);
} else {
- parameterElement.type = buildType(serializedParameter.type);
+ if (serializedParameter.isInitializingFormal &&
+ serializedParameter.hasImplicitType) {
+ // The type is inherited from the matching field.
+ parameterElement.type = fieldTypes[serializedParameter.name] ??
+ summaryResynthesizer.typeProvider.dynamicType;
+ } else {
+ parameterElement.type = buildType(serializedParameter.type);
+ }
parameterElement.hasImplicitType = serializedParameter.hasImplicitType;
}
switch (serializedParameter.kind) {
@@ -899,8 +915,7 @@ class _LibraryResynthesizer {
if (type.paramReference != 0) {
// TODO(paulberry): make this work for generic methods.
return currentTypeParameters[
- currentTypeParameters.length - type.paramReference]
- .type;
+ currentTypeParameters.length - type.paramReference].type;
} else {
// TODO(paulberry): handle references to things other than classes (note:
// this should only occur in the case of erroneous code).
@@ -1036,6 +1051,7 @@ class _LibraryResynthesizer {
element.static = serializedVariable.isStatic;
holder.addField(element);
buildImplicitAccessors(element, holder);
+ fieldTypes[element.name] = element.type;
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698