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); |