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

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

Issue 1559123002: Clean up resynthesis of typeArguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 12 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/dart/element/type.dart ('k') | no next file » | 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 2addadb3dd28fc29ccac8501dacea1d220970554..b66088678d103aca057461aad318c646fc87c135 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -25,66 +25,6 @@ typedef PrelinkedLibrary GetPrelinkedSummaryCallback(String uri);
typedef UnlinkedUnit GetUnlinkedSummaryCallback(String uri);
/**
- * Specialization of [FunctionTypeImpl] used for function types resynthesized
- * from summaries.
- */
-class ResynthesizedFunctionTypeImpl extends FunctionTypeImpl
- with ResynthesizedType {
- final SummaryResynthesizer summaryResynthesizer;
-
- ResynthesizedFunctionTypeImpl(
- FunctionTypeAliasElement element, String name, this.summaryResynthesizer)
- : super.elementWithName(element, name);
-
- int get _numTypeParameters {
- FunctionTypeAliasElement element = this.element;
- return element.typeParameters.length;
- }
-}
-
-/**
- * Specialization of [InterfaceTypeImpl] used for interface types resynthesized
- * from summaries.
- */
-class ResynthesizedInterfaceTypeImpl extends InterfaceTypeImpl
- with ResynthesizedType {
- final SummaryResynthesizer summaryResynthesizer;
-
- ResynthesizedInterfaceTypeImpl(
- ClassElement element, String name, this.summaryResynthesizer)
- : super.elementWithName(element, name);
-
- int get _numTypeParameters => element.typeParameters.length;
-}
-
-/**
- * Common code for types resynthesized from summaries. This code takes care of
- * filling in the appropriate number of copies of `dynamic` when it is queried
- * for type parameters on a bare type reference (i.e. it converts `List` to
- * `List<dynamic>`).
- */
-abstract class ResynthesizedType implements DartType {
- /**
- * The type arguments, if known. Otherwise `null`.
- */
- List<DartType> _typeArguments;
-
- SummaryResynthesizer get summaryResynthesizer;
-
- List<DartType> get typeArguments {
- if (_typeArguments == null) {
- // Default to replicating "dynamic" as many times as the class element
- // requires.
- _typeArguments = new List<DartType>.filled(
- _numTypeParameters, summaryResynthesizer.typeProvider.dynamicType);
- }
- return _typeArguments;
- }
-
- int get _numTypeParameters;
-}
-
-/**
* Implementation of [ElementResynthesizer] used when resynthesizing an element
* model from summaries.
*/
@@ -812,33 +752,36 @@ class _LibraryResynthesizer {
partUri = referencedLibraryUri;
}
}
- ResynthesizedType resynthesizedType;
ElementLocationImpl location = new ElementLocationImpl.con3(
<String>[referencedLibraryUri, partUri, reference.name]);
+ List<DartType> typeArguments = const <DartType>[];
+ if (referenceResolution.numTypeParameters != 0) {
+ typeArguments = <DartType>[];
+ for (int i = 0; i < referenceResolution.numTypeParameters; i++) {
+ if (i < type.typeArguments.length) {
+ typeArguments.add(buildType(type.typeArguments[i]));
+ } else {
+ typeArguments.add(summaryResynthesizer.typeProvider.dynamicType);
+ }
+ }
+ }
switch (referenceResolution.kind) {
case PrelinkedReferenceKind.classOrEnum:
- resynthesizedType = new ResynthesizedInterfaceTypeImpl(
+ return new InterfaceTypeImpl.elementWithNameAndArgs(
new ClassElementHandle(summaryResynthesizer, location),
reference.name,
- summaryResynthesizer);
- break;
+ typeArguments);
case PrelinkedReferenceKind.typedef:
- resynthesizedType = new ResynthesizedFunctionTypeImpl(
+ return new FunctionTypeImpl.elementWithNameAndArgs(
new FunctionTypeAliasElementHandle(
summaryResynthesizer, location),
reference.name,
- summaryResynthesizer);
- break;
+ typeArguments);
default:
// TODO(paulberry): figure out how to handle this case (which should
// only occur in the event of erroneous code).
throw new UnimplementedError();
}
- if (type.typeArguments.isNotEmpty) {
- resynthesizedType._typeArguments =
- type.typeArguments.map(buildType).toList();
- }
- return resynthesizedType;
}
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698