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

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

Issue 1658253002: Serialize constant instance creation of generic classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove the special case for unnamed constructors from _getElementReferenceId(). 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 5c50d2e14fdc8520923aa7c0617ee06944f47ebb..4d903184321a0f7cc6093266f916652a3f0f913e 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -678,7 +678,7 @@ class _CompilationUnitSerializer {
* Serialize the given [type] into a [EntityRef]. If [slot] is provided,
* it should be included in the [EntityRef]. If [linked] is true, any
* references that are created will be populated into [linkedReferences] but
- * [not [unlinkedReferences].
+ * not [unlinkedReferences].
*
* [context] is the element within which the [EntityRef] will be
* interpreted; this is used to serialize type parameters.
@@ -830,9 +830,6 @@ class _CompilationUnitSerializer {
int _getElementReferenceId(Element element, {bool linked: false}) {
return referenceMap.putIfAbsent(element, () {
- if (element is ConstructorElement && element.displayName.isEmpty) {
- return _getElementReferenceId(element.enclosingElement, linked: linked);
- }
LibraryElement dependentLibrary = element?.library;
int unit;
if (dependentLibrary == null) {
@@ -911,10 +908,23 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
@override
EntityRefBuilder serializeConstructorName(ConstructorName constructor) {
- ConstructorElement element = constructor.staticElement;
- assert(element != null);
- int referenceId = serializer._getElementReferenceId(element);
- return new EntityRefBuilder(reference: referenceId);
+ DartType type = constructor.type.type;
+ EntityRefBuilder typeRef = serializer.serializeTypeRef(type, null);
+ if (constructor.name == null) {
+ return typeRef;
+ } else {
+ int typeId = typeRef.reference;
+ LinkedReference typeLinkedRef = serializer.linkedReferences[typeId];
+ serializer.unlinkedReferences.add(new UnlinkedReferenceBuilder(
+ name: constructor.name.name, prefixReference: typeId));
+ int refId = serializer.linkedReferences.length;
+ serializer.linkedReferences.add(new LinkedReferenceBuilder(
+ kind: ReferenceKind.constructor,
+ dependency: typeLinkedRef.dependency,
+ unit: typeLinkedRef.unit));
+ return new EntityRefBuilder(
+ reference: refId, typeArguments: typeRef.typeArguments);
+ }
}
EntityRefBuilder serializeIdentifier(Identifier identifier) {
« 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