Chromium Code Reviews| 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); |
| + } |
| } |