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

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: Created 3 years, 10 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..54d577c6840c0a67145bd9eb4ae9b1134e380048 100644
--- a/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
+++ b/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
@@ -27,12 +27,26 @@ 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();
+// Procedure target = node.interfaceTarget;
karlklose 2017/02/24 12:07:23 Why is this commented out?
Dmitry Stefantsov 2017/02/28 11:32:15 I should have removed that. The idea is actually t
+// target.function.typeParameters.clear();
return node;
}
@@ -96,7 +110,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 +131,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