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

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

Issue 1686713002: Add support for redirectedConstructor to summaries. (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 | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.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 0a71496444444bf9e37861ad870854b1333120c0..198943a38db94e07ee4840c0c5c8fe0f1ac4a5f2 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -467,28 +467,6 @@ class _ConstExprBuilder {
throw new StateError('Unsupported type $type');
}
- /**
- * Return the [ConstructorElement] by applying [typeArgumentRefs] to the
- * given linked [info]. Both cases when [info] is a [ClassElement] and
- * [ConstructorElement] are supported.
- */
- _DeferredConstructorElement _createConstructorElement(
- _ReferenceInfo info, List<EntityRef> typeArgumentRefs) {
- bool isClass = info.element is ClassElement;
- _ReferenceInfo classInfo = isClass ? info : info.enclosing;
- List<DartType> typeArguments =
- typeArgumentRefs.map(resynthesizer.buildType).toList();
- InterfaceType classType = classInfo.buildType((i) {
- if (i < typeArguments.length) {
- return typeArguments[i];
- } else {
- return DynamicTypeImpl.instance;
- }
- }, const <int>[]);
- String name = isClass ? '' : info.name;
- return new _DeferredConstructorElement(classType, name);
- }
-
InterpolationElement _newInterpolationElement(Expression expr) {
if (expr is SimpleStringLiteral) {
return new InterpolationString(expr.literal, expr.value);
@@ -536,7 +514,7 @@ class _ConstExprBuilder {
'${info.element?.runtimeType}');
}
_DeferredConstructorElement constructorElement =
- _createConstructorElement(info, ref.typeArguments);
+ resynthesizer._createConstructorElement(info, ref.typeArguments);
// prepare arguments
List<Expression> arguments;
{
@@ -939,6 +917,25 @@ class _LibraryResynthesizer {
.constantInitializers
.map(buildConstantInitializer)
.toList();
+ if (serializedExecutable.isRedirectedConstructor) {
+ if (serializedExecutable.isFactory) {
+ EntityRef redirectedConstructor =
+ serializedExecutable.redirectedConstructor;
+ currentConstructor.redirectedConstructor = _createConstructorElement(
+ referenceInfos[redirectedConstructor.reference],
+ redirectedConstructor.typeArguments);
+ } else {
+ List<String> locationComponents =
+ currentCompilationUnit.location.components.toList();
+ locationComponents.add(classType.name);
+ locationComponents.add(serializedExecutable.redirectedConstructorName);
+ currentConstructor.redirectedConstructor =
+ new _DeferredConstructorElement._(
+ classType,
+ serializedExecutable.redirectedConstructorName,
+ new ElementLocationImpl.con3(locationComponents));
+ }
+ }
holder.addConstructor(currentConstructor);
currentConstructor = null;
}
@@ -1891,6 +1888,27 @@ class _LibraryResynthesizer {
<String>['dart:core', 'dart:core', 'String', 'length?']));
/**
+ * Return the [ConstructorElement] by applying [typeArgumentRefs] to the
+ * given linked [info]. Both cases when [info] is a [ClassElement] and
+ * [ConstructorElement] are supported.
+ */
+ _DeferredConstructorElement _createConstructorElement(
+ _ReferenceInfo info, List<EntityRef> typeArgumentRefs) {
+ bool isClass = info.element is ClassElement;
+ _ReferenceInfo classInfo = isClass ? info : info.enclosing;
+ List<DartType> typeArguments = typeArgumentRefs.map(buildType).toList();
+ InterfaceType classType = classInfo.buildType((i) {
+ if (i < typeArguments.length) {
+ return typeArguments[i];
+ } else {
+ return DynamicTypeImpl.instance;
+ }
+ }, const <int>[]);
+ String name = isClass ? '' : info.name;
+ return new _DeferredConstructorElement(classType, name);
+ }
+
+ /**
* If the given [kind] is a top-level or class member property accessor, and
* the given [name] does not end with `=`, i.e. does not denote a setter,
* return the getter identifier by appending `?`.
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698