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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10913133: Allow closures inside lazy initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 2 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 | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 373d01e14180cde4112be7ea551770e63a273bd2..cdb4285172ec671d7d92ddbb4c93a28800f8a93d 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1372,9 +1372,20 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
} else {
name = node.name.asIdentifier().source;
}
+ // TODO(ahe): we shouldn't use the scope to get the enclosing element. This
+ // is currently needed so that nested functions get their correct enclosing
+ // element.
+ Element functionEnclosing = scope.element;
+ if (functionEnclosing.kind == ElementKind.VARIABLE_LIST) {
+ compiler.internalError("Bad enclosing element", node: node);
+ }
+ if (functionEnclosing.isLibrary()) {
+ // We are in a static initializers.
+ functionEnclosing = enclosingElement;
+ }
FunctionElement enclosing = new FunctionElement.node(
name, node, ElementKind.FUNCTION, Modifiers.EMPTY,
- scope.element);
+ functionEnclosing);
setupFunction(node, enclosing);
defineElement(node, enclosing, doAddToScope: node.name !== null);
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698