Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java |
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java |
| index ddd8f9b152a05106736e82c45fee7c110db09779..3d84197264c13cae2745b6b6f0e0500912b818f4 100644 |
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java |
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java |
| @@ -13,6 +13,7 @@ |
| */ |
| package com.google.dart.engine.internal.resolver; |
| +import com.google.dart.engine.ast.Annotation; |
| import com.google.dart.engine.ast.ArgumentList; |
| import com.google.dart.engine.ast.AsExpression; |
| import com.google.dart.engine.ast.AssertStatement; |
| @@ -132,6 +133,12 @@ public class ResolverVisitor extends ScopedVisitor { |
| private Comment commentBeforeFunction = null; |
| /** |
| + * A metadata before a class should be resolved in the library scope, not in the scope of a class. |
| + * So, we resolve the metadata and ignore it when in the scope of the enclosing class. |
| + */ |
| + private AstNode classWithAlreadyResolvedMetadata = null; |
|
Brian Wilkerson
2014/05/07 19:27:05
Will this ever be different than the enclosingClas
scheglov
2014/05/07 19:43:05
Not quite.
The "enclosingClass" field is an Elemen
|
| + |
| + /** |
| * The object keeping track of which elements have had their types overridden. |
| */ |
| private TypeOverrideManager overrideManager = new TypeOverrideManager(); |
| @@ -224,6 +231,14 @@ public class ResolverVisitor extends ScopedVisitor { |
| } |
| @Override |
| + public Void visitAnnotation(Annotation node) { |
| + if (node.getParent() == classWithAlreadyResolvedMetadata) { |
| + return null; |
| + } |
| + return super.visitAnnotation(node); |
| + } |
| + |
| + @Override |
| public Void visitAsExpression(AsExpression node) { |
| super.visitAsExpression(node); |
| overrideExpression(node.getExpression(), node.getType().getType()); |
| @@ -308,6 +323,12 @@ public class ResolverVisitor extends ScopedVisitor { |
| @Override |
| public Void visitClassDeclaration(ClassDeclaration node) { |
| + // Resolve the class metadata in the library scope. |
| + if (node.getMetadata() != null) { |
| + node.getMetadata().accept(this); |
| + } |
| + classWithAlreadyResolvedMetadata = node; |
| + // Continue the class resolution. |
| ClassElement outerType = enclosingClass; |
| try { |
| enclosingClass = node.getElement(); |
| @@ -316,6 +337,7 @@ public class ResolverVisitor extends ScopedVisitor { |
| } finally { |
| typeAnalyzer.setThisType(outerType == null ? null : outerType.getType()); |
| enclosingClass = outerType; |
| + classWithAlreadyResolvedMetadata = null; |
| } |
| return null; |
| } |