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

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

Issue 1902593005: In summary linker, drop trailing type args of type `dynamic`. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 7b7d0e5732f9c1843c876d29190529b137b28c37..0aff6d209ff2d8f0d3aa0297bb0d2d086fc078d2 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -166,12 +166,8 @@ EntityRefBuilder _createLinkedType(
if (type is InterfaceType) {
ClassElementForLink element = type.element;
result.reference = compilationUnit.addReference(element);
- if (type.typeArguments.isNotEmpty) {
- result.typeArguments = type.typeArguments
- .map((DartType t) =>
- _createLinkedType(t, compilationUnit, typeParameterContext))
- .toList();
- }
+ _storeTypeArguments(
+ type.typeArguments, result, compilationUnit, typeParameterContext);
return result;
} else if (type is DynamicTypeImpl) {
result.reference = compilationUnit.addRawReference('dynamic');
@@ -193,32 +189,20 @@ EntityRefBuilder _createLinkedType(
result.reference =
compilationUnit.addReference(element.innermostExecutable);
result.implicitFunctionTypeIndices = element.implicitFunctionTypeIndices;
- if (type.typeArguments.isNotEmpty) {
- result.typeArguments = type.typeArguments
- .map((DartType t) =>
- _createLinkedType(t, compilationUnit, typeParameterContext))
- .toList();
- }
+ _storeTypeArguments(
+ type.typeArguments, result, compilationUnit, typeParameterContext);
return result;
}
if (element is TopLevelFunctionElementForLink) {
result.reference = compilationUnit.addReference(element);
- if (type.typeArguments.isNotEmpty) {
- result.typeArguments = type.typeArguments
- .map((DartType t) =>
- _createLinkedType(t, compilationUnit, typeParameterContext))
- .toList();
- }
+ _storeTypeArguments(
+ type.typeArguments, result, compilationUnit, typeParameterContext);
return result;
}
if (element is MethodElementForLink) {
result.reference = compilationUnit.addReference(element);
- if (type.typeArguments.isNotEmpty) {
- result.typeArguments = type.typeArguments
- .map((DartType t) =>
- _createLinkedType(t, compilationUnit, typeParameterContext))
- .toList();
- }
+ _storeTypeArguments(
+ type.typeArguments, result, compilationUnit, typeParameterContext);
return result;
}
// TODO(paulberry): implement other cases.
@@ -229,6 +213,34 @@ EntityRefBuilder _createLinkedType(
}
/**
+ * Store the given [typeArguments] in [encodedType], using [compilationUnit] and
+ * [typeParameterContext] to serialize them.
+ *
+ * Trailing arguments of type `dynamic` are dropped.
+ */
+void _storeTypeArguments(
+ List<DartType> typeArguments,
+ EntityRefBuilder encodedType,
+ CompilationUnitElementInBuildUnit compilationUnit,
+ TypeParameterizedElementForLink typeParameterContext) {
+ int count = typeArguments.length;
+ while (count > 0) {
+ if (typeArguments[count - 1].isDynamic) {
+ count--;
+ } else {
+ List<EntityRefBuilder> encodedTypeArguments =
+ new List<EntityRefBuilder>(count);
+ for (int i = 0; i < count; i++) {
+ encodedTypeArguments[i] = _createLinkedType(
+ typeArguments[i], compilationUnit, typeParameterContext);
+ }
+ encodedType.typeArguments = encodedTypeArguments;
+ break;
+ }
+ }
+}
+
+/**
* Type of the callback used by [link] and [relink] to request
* [LinkedLibrary] objects from other build units.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698