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

Unified Diff: pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart

Issue 2713163002: Pass type arguments as a list in generic methods invocations (Closed)
Patch Set: Simplify 'isGenericMethod' procedure Created 3 years, 9 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
Index: pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
diff --git a/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart b/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
index aafff7d93c0c32c3fd6b2aa98d2da4c21a17b80b..1a103f6abe97f365d22443d63bb31131350e6696 100644
--- a/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
+++ b/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
@@ -27,12 +27,24 @@ class Erasure extends Transformer with DartTypeVisitor<DartType> {
}
TreeNode removeTypeArgumentsOfStaticCall(StaticInvocation node) {
- Class cls = node.target.parent;
- if (removeTypeParameters(cls)) {
- node.arguments.types.clear();
- Procedure target = node.target;
- target.function.typeParameters.clear();
+ if (node.target.parent is Class) {
+ Class cls = node.target.parent;
+ if (!removeTypeParameters(cls)) {
+ return node;
+ }
+ } else {
+ // If parent is a Library, then a global procedure is invoked, and it may
+ // be a generic function, so we need to remove type arguments anyway.
+ assert(node.target.parent is Library);
}
+ node.arguments.types.clear();
+ Procedure target = node.target;
+ target.function.typeParameters.clear();
+ return node;
+ }
+
+ TreeNode removeTypeArgumentOfMethodInvocation(MethodInvocation node) {
+ node.arguments.types.clear();
return node;
}
@@ -96,7 +108,8 @@ class Erasure extends Transformer with DartTypeVisitor<DartType> {
@override
StaticInvocation visitStaticInvocation(StaticInvocation node) {
node.transformChildren(this);
- if (node.target.kind == ProcedureKind.Factory) {
+ if (node.target.kind == ProcedureKind.Factory ||
+ node.target.kind == ProcedureKind.Method) {
node = removeTypeArgumentsOfStaticCall(node);
}
return node;
@@ -116,4 +129,10 @@ class Erasure extends Transformer with DartTypeVisitor<DartType> {
}
return node;
}
+
+ @override
+ Expression visitMethodInvocation(MethodInvocation node) {
+ node.transformChildren(this);
+ return removeTypeArgumentOfMethodInvocation(node);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698