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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java

Issue 277523002: Issue 17894. Scope of metadata on a class is the defining library, not the class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698