Index: pkg/compiler/lib/src/ssa/kernel_impact.dart |
diff --git a/pkg/compiler/lib/src/ssa/kernel_impact.dart b/pkg/compiler/lib/src/ssa/kernel_impact.dart |
index fef8f82a6282ad237893285a679b9207ed255810..f03bd1f61372d7b4ae273ad2d6e43e6eb6ff3e92 100644 |
--- a/pkg/compiler/lib/src/ssa/kernel_impact.dart |
+++ b/pkg/compiler/lib/src/ssa/kernel_impact.dart |
@@ -244,10 +244,17 @@ class KernelImpactBuilder extends ir.Visitor { |
@override |
void visitMethodInvocation(ir.MethodInvocation invocation) { |
- invocation.receiver.accept(this); |
+ var receiver = invocation.receiver; |
+ if (receiver is ir.VariableGet && |
+ receiver.variable.isFinal && |
+ receiver.variable.parent is ir.FunctionDeclaration) { |
+ // Invocation of a local function. No need for dynamic use. |
+ } else { |
+ invocation.receiver.accept(this); |
+ impactBuilder.registerDynamicUse( |
+ new DynamicUse(astAdapter.getSelector(invocation), null)); |
+ } |
_visitArguments(invocation.arguments); |
- impactBuilder.registerDynamicUse( |
- new DynamicUse(astAdapter.getSelector(invocation), null)); |
} |
@override |
@@ -280,5 +287,12 @@ class KernelImpactBuilder extends ir.Visitor { |
} |
@override |
+ void visitFunctionDeclaration(ir.FunctionDeclaration node) { |
+ impactBuilder |
+ .registerStaticUse(new StaticUse.closure(astAdapter.getElement(node))); |
+ node.visitChildren(this); |
+ } |
+ |
+ @override |
void defaultNode(ir.Node node) => node.visitChildren(this); |
} |