Index: pkg/kernel/lib/type_algebra.dart |
diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart |
index c86f4d21f80ec258cf0fa3dc8eb9806cad3c2852..47fbf05c3c241bdd1a56b6c80ef9d89a8269a8d7 100644 |
--- a/pkg/kernel/lib/type_algebra.dart |
+++ b/pkg/kernel/lib/type_algebra.dart |
@@ -173,6 +173,14 @@ abstract class Substitution { |
type.classNode.typeParameters, type.typeArguments)); |
} |
+ /// Substitutes the type parameters on the typedef of [type] with the |
+ /// type arguments provided in [type]. |
+ static Substitution fromTypedefType(TypedefType type) { |
+ if (type.typeArguments.isEmpty) return _NullSubstitution.instance; |
+ return fromMap(new Map<TypeParameter, DartType>.fromIterables( |
+ type.typedefNode.typeParameters, type.typeArguments)); |
+ } |
+ |
/// Substitutes the Nth parameter in [parameters] with the Nth type in |
/// [types]. |
static Substitution fromPairs( |
@@ -375,6 +383,14 @@ abstract class _TypeSubstitutor extends DartTypeVisitor<DartType> { |
return new InterfaceType(node.classNode, typeArguments); |
} |
+ DartType visitTypedefType(TypedefType node) { |
+ if (node.typeArguments.isEmpty) return node; |
+ int before = useCounter; |
+ var typeArguments = node.typeArguments.map(visit).toList(); |
+ if (useCounter == before) return node; |
+ return new TypedefType(node.typedefNode, typeArguments); |
+ } |
+ |
List<TypeParameter> freshTypeParameters(List<TypeParameter> parameters) { |
if (parameters.isEmpty) return const <TypeParameter>[]; |
return parameters.map(freshTypeParameter).toList(); |
@@ -655,6 +671,10 @@ class _OccurrenceVisitor extends DartTypeVisitor<bool> { |
return node.typeArguments.any(visit); |
} |
+ bool visitTypedefType(TypedefType node) { |
+ return node.typeArguments.any(visit); |
+ } |
+ |
bool visitFunctionType(FunctionType node) { |
return node.typeParameters.any(handleTypeParameter) || |
node.positionalParameters.any(visit) || |