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

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

Issue 1699243003: Serialize and resynthesize unresolved constant instance creations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add more tests. 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 | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | 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 f6905647a083385498c531c9578b0ec42141bcac..9429f300457da140bd60c7b318a7f5e1ab8476d6 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -523,19 +523,51 @@ class _ConstExprBuilder {
EntityRef ref = uc.references[refPtr++];
_ReferenceInfo info = resynthesizer.referenceInfos[ref.reference];
// prepare ConstructorElement
+ TypeName typeNode;
String constructorName;
- if (info.element is ConstructorElement) {
- constructorName = info.name;
- } else if (info.element is ClassElement) {
- constructorName = null;
+ ConstructorElement constructorElement;
+ if (info.element != null) {
+ if (info.element is ConstructorElement) {
+ constructorName = info.name;
+ } else if (info.element is ClassElement) {
+ constructorName = null;
+ } else {
+ throw new StateError('Unsupported element for invokeConstructor '
+ '${info.element?.runtimeType}');
+ }
+ InterfaceType definingType =
+ resynthesizer._createConstructorDefiningType(info, ref.typeArguments);
+ constructorElement =
+ resynthesizer._createConstructorElement(definingType, info);
+ typeNode = _buildTypeAst(definingType);
} else {
- throw new StateError('Unsupported element for invokeConstructor '
- '${info.element?.runtimeType}');
+ if (info.enclosing != null) {
+ if (info.enclosing.enclosing != null) {
+ PrefixedIdentifier typeName = AstFactory.identifier5(
+ info.enclosing.enclosing.name, info.enclosing.name);
+ typeName.prefix.staticElement = info.enclosing.enclosing.element;
+ typeName.identifier.staticElement = info.enclosing.element;
+ typeName.identifier.staticType = info.enclosing.type;
+ typeNode = AstFactory.typeName3(typeName);
+ typeNode.type = info.enclosing.type;
+ constructorName = info.name;
+ } else if (info.enclosing.element != null) {
+ SimpleIdentifier typeName =
+ AstFactory.identifier3(info.enclosing.name);
+ typeName.staticElement = info.enclosing.element;
+ typeName.staticType = info.enclosing.type;
+ typeNode = AstFactory.typeName3(typeName);
+ typeNode.type = info.enclosing.type;
+ constructorName = info.name;
+ } else {
+ typeNode = AstFactory.typeName3(
+ AstFactory.identifier5(info.enclosing.name, info.name));
+ constructorName = null;
+ }
+ } else {
+ typeNode = AstFactory.typeName4(info.name);
+ }
}
- InterfaceType definingType =
- resynthesizer._createConstructorDefiningType(info, ref.typeArguments);
- ConstructorElement constructorElement =
- resynthesizer._createConstructorElement(definingType, info);
// prepare arguments
List<Expression> arguments;
{
@@ -550,8 +582,6 @@ class _ConstExprBuilder {
arguments[index] = AstFactory.namedExpression2(name, arguments[index]);
}
}
- // create TypeName
- TypeName typeNode = _buildTypeAst(definingType);
// create ConstructorName
ConstructorName constructorNode;
if (constructorName != null) {
@@ -1825,7 +1855,6 @@ class _LibraryResynthesizer {
referenceInfos = new List<_ReferenceInfo>(numLinkedReferences);
for (int i = 0; i < numLinkedReferences; i++) {
LinkedReference linkedReference = linkedUnit.references[i];
- _ReferenceInfo enclosingInfo = null;
String name;
int containingReference;
if (i < numUnlinkedReferences) {
@@ -1835,6 +1864,8 @@ class _LibraryResynthesizer {
name = linkedUnit.references[i].name;
containingReference = linkedUnit.references[i].containingReference;
}
+ _ReferenceInfo enclosingInfo =
+ containingReference != 0 ? referenceInfos[containingReference] : null;
Element element;
DartType type;
int numTypeParameters = linkedReference.numTypeParameters;
@@ -1849,10 +1880,8 @@ class _LibraryResynthesizer {
element = type.element;
} else {
List<String> locationComponents;
- if (containingReference != 0 &&
- referenceInfos[containingReference].element is ClassElement) {
+ if (enclosingInfo != null && enclosingInfo.element is ClassElement) {
String identifier = _getElementIdentifier(name, linkedReference.kind);
- enclosingInfo = referenceInfos[containingReference];
locationComponents =
enclosingInfo.element.location.components.toList();
locationComponents.add(identifier);
« no previous file with comments | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698