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

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

Issue 10349008: Set the right context to resolve types of fields, closures and parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | no next file » | 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 67f338b387a5da84c0cb49992898cd2c3f47e8eb..b4971a3a0c282b7e580e96ad44df99fc688c3be5 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -577,12 +577,22 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
this.enclosingElement = element,
inInstanceContext = element.isInstanceMember()
|| element.isGenerativeConstructor(),
- this.context = element.isMember()
- ? new ClassScope(element.enclosingElement, element.getLibrary())
- : new TopScope(element.getLibrary()),
this.currentClass = element.isMember() ? element.enclosingElement : null,
this.statementScope = new StatementScope(),
- super(compiler);
+ super(compiler) {
+ LibraryElement library = element.getLibrary();
kasperl 2012/05/03 13:25:29 How about a helper function for this while loop? I
+ while (element !== null) {
+ if (element.isMember()) {
+ this.context = new ClassScope(element.enclosingElement, library);
+ break;
+ } else {
+ element = element.enclosingElement;
+ }
+ }
+ if (this.context === null) {
+ this.context = new TopScope(library);
+ }
+ }
Element lookup(Node node, SourceString name) {
Element result = context.lookup(name);
@@ -1068,8 +1078,11 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
if (send !== null) {
typeName = send.selector;
}
- if (typeName.source == Types.VOID) return compiler.types.voidType.element;
- if (send !== null) {
+ if (typeName.source == Types.VOID) {
+ return compiler.types.voidType.element;
+ } else if (typeName.source.stringValue === Keyword.FACTORY.stringValue) {
kasperl 2012/05/03 13:25:29 === on string values seems a bit fishy. Maybe chan
+ return compiler.dynamicClass;
+ } else if (send !== null) {
Element e = context.lookup(send.receiver.asIdentifier().source);
if (e !== null && e.kind === ElementKind.PREFIX) {
// The receiver is a prefix. Lookup in the imported members.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698