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

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

Issue 1621763002: Use the explicit string 'dynamic' to refer to dynamic 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 | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 6cb6dc6b71b87f7f5f3c961ebedbae41f2df4d98..d4d141069d983e6896f5a499f1f248535d3f38be 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -33,7 +33,7 @@ ReferenceKind _getReferenceKind(Element element) {
kind = ReferenceKind.topLevelPropertyAccessor;
} else if (element is FunctionTypeAliasElement) {
kind = ReferenceKind.typedef;
- } else if (element is ClassElement) {
+ } else if (element is ClassElement || element is DynamicElementImpl) {
kind = ReferenceKind.classOrEnum;
} else if (element is FunctionElement) {
kind = ReferenceKind.topLevelFunction;
@@ -410,13 +410,6 @@ class _CompilationUnitSerializer {
}
/**
- * Return the index of the entry in the references table
- * ([UnlinkedLibrary.references] and [LinkedLibrary.references])
- * representing the pseudo-type `dynamic`.
- */
- int serializeDynamicReference() => 0;
-
- /**
* Serialize the given [enumElement], creating an [UnlinkedEnum].
*/
UnlinkedEnumBuilder serializeEnum(ClassElement enumElement) {
@@ -600,12 +593,11 @@ class _CompilationUnitSerializer {
assert(type.isDynamic);
if (type is UndefinedTypeImpl) {
return serializeUnresolvedReference();
- } else {
- return serializeDynamicReference();
}
- } else {
- return _getElementReferenceId(element, linked: linked);
+ // Note: for a type which is truly `dynamic`, fall through to use
+ // [_getElementReferenceId].
}
+ return _getElementReferenceId(element, linked: linked);
}
/**
@@ -757,12 +749,19 @@ class _CompilationUnitSerializer {
}
int _getElementReferenceId(Element element, {bool linked: false}) {
- LibraryElement dependentLibrary = element.library;
return referenceMap.putIfAbsent(element, () {
- CompilationUnitElement unitElement =
- element.getAncestor((Element e) => e is CompilationUnitElement);
- int unit = dependentLibrary.units.indexOf(unitElement);
- assert(unit != -1);
+ LibraryElement dependentLibrary = element.library;
+ int unit;
+ if (element.library == null) {
+ assert(element == librarySerializer.typeProvider.dynamicType.element);
+ unit = 0;
+ dependentLibrary = librarySerializer.libraryElement;
+ } else {
+ CompilationUnitElement unitElement =
+ element.getAncestor((Element e) => e is CompilationUnitElement);
+ unit = dependentLibrary.units.indexOf(unitElement);
+ assert(unit != -1);
+ }
int numTypeParameters = 0;
if (element is TypeParameterizedElement) {
numTypeParameters = element.typeParameters.length;
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698