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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2814443005: Fix for summarization of generic function type aliases and support for resynthesizing. (Closed)
Patch Set: Created 3 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 | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index fb7779f3cc02cf192e6cc77ab4c71b8f57c9a71a..f5b2df67ad4136ad981f5d64e9dde6765e2ffdcc 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -5233,6 +5233,27 @@ class GenericTypeAliasElementImpl extends ElementImpl
return null;
}
+ /**
+ * Return the type of the function defined by this typedef after substituting
+ * the given [typeArguments] for the type parameters defined for this typedef
+ * (but not the type parameters defined by the function). If the number of
+ * [typeArguments] does not match the number of type parameters, then
+ * `dynamic` will be used in place of each of the type arguments.
+ */
+ FunctionType typeAfterSubstitution(List<DartType> typeArguments) {
+ FunctionType functionType = function.type;
+ List<TypeParameterElement> parameterElements = typeParameters;
+ List<DartType> parameterTypes =
+ TypeParameterTypeImpl.getTypes(parameterElements);
+ int parameterCount = parameterTypes.length;
+ if (typeArguments == null ||
+ parameterElements.length != typeArguments.length) {
+ DartType dynamicType = DynamicElementImpl.instance.type;
+ typeArguments = new List<DartType>.filled(parameterCount, dynamicType);
+ }
+ return functionType.substitute2(typeArguments, parameterTypes);
+ }
+
@override
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698