Index: pkg/compiler/lib/src/kernel/kernel_visitor.dart |
diff --git a/pkg/compiler/lib/src/kernel/kernel_visitor.dart b/pkg/compiler/lib/src/kernel/kernel_visitor.dart |
index 26f3b3a01fba3760919e1a9c8c81d8464dfe8058..415483f4c371f9fc985d87784e52833e0b56c13a 100644 |
--- a/pkg/compiler/lib/src/kernel/kernel_visitor.dart |
+++ b/pkg/compiler/lib/src/kernel/kernel_visitor.dart |
@@ -1689,8 +1689,12 @@ class KernelVisitor extends Object |
LocalFunctionElement localFunction, NodeList parameters, Node body, _) { |
return withCurrentElement(localFunction, () { |
ir.VariableDeclaration local = getLocal(localFunction)..isFinal = true; |
- return new ir.FunctionDeclaration( |
+ ir.FunctionDeclaration function = new ir.FunctionDeclaration( |
local, buildFunctionNode(localFunction, body)); |
+ // Closures can escape their context and we must therefore store them |
+ // globally to include them in the world computation. |
+ kernel.localFunctions[localFunction] = function; |
+ return function; |
}); |
} |