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

Unified Diff: pkg/kernel/lib/type_algebra.dart

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor 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/kernel/lib/transformations/treeshaker.dart ('k') | pkg/kernel/lib/type_environment.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) ||
« no previous file with comments | « pkg/kernel/lib/transformations/treeshaker.dart ('k') | pkg/kernel/lib/type_environment.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698