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

Unified Diff: runtime/vm/parser.cc

Issue 9835070: Do not share local function between closurized and non-closurized enclosing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | tests/language/src/ImplicitClosure2Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 5792)
+++ runtime/vm/parser.cc (working copy)
@@ -3925,17 +3925,23 @@
}
intptr_t function_pos = token_index_;
- // Check whether we have parsed this closure before, in a previous
+ // Check whether we have parsed this closure function before, in a previous
// compilation. If so, reuse the function object, else create a new one
// and register it in the current class.
+ // Note that we cannot share the same closure function between the closurized
+ // and non-closurized versions of the same parent function.
Function& function = Function::ZoneHandle();
bool is_new_closure = false;
+ // TODO(hausner): There could be two different closures at the given
+ // function_pos, one enclosed in a closurized function and one enclosed in the
+ // non-closurized version of this same function.
function = current_class().LookupClosureFunction(function_pos);
- if (function.IsNull() || (function.token_index() != function_pos)) {
+ if (function.IsNull() || (function.token_index() != function_pos) ||
+ (function.parent_function() != current_function().raw())) {
is_new_closure = true;
function = Function::NewClosureFunction(*function_name,
- current_function(),
- function_pos);
+ current_function(),
+ function_pos);
function.set_result_type(result_type);
current_class().AddClosureFunction(function);
}
« no previous file with comments | « no previous file | tests/language/src/ImplicitClosure2Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698