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: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 296513015: Revert "Handle metadata on nested function parameters." (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
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index c7e4611cf317e33eef8183fc9bc5d55879c4e439..bf1cf2267e9232baf26acf3007537b504545a1a5 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -259,11 +259,8 @@ class ResolverTask extends CompilerTask {
return measure(() {
if (Elements.isErroneousElement(element)) return null;
- processMetadata([result]) {
- for (MetadataAnnotation metadata in element.metadata) {
- metadata.ensureResolved(compiler);
- }
- return result;
+ for (MetadataAnnotation metadata in element.metadata) {
+ metadata.ensureResolved(compiler);
}
ElementKind kind = element.kind;
@@ -271,19 +268,18 @@ class ResolverTask extends CompilerTask {
identical(kind, ElementKind.FUNCTION) ||
identical(kind, ElementKind.GETTER) ||
identical(kind, ElementKind.SETTER)) {
- return processMetadata(resolveMethodElement(element));
+ return resolveMethodElement(element);
}
- if (identical(kind, ElementKind.FIELD)) {
- return processMetadata(resolveField(element));
- }
+ if (identical(kind, ElementKind.FIELD)) return resolveField(element);
+
if (element.isClass) {
ClassElement cls = element;
cls.ensureResolved(compiler);
- return processMetadata();
+ return null;
} else if (element.isTypedef) {
TypedefElement typdef = element;
- return processMetadata(resolveTypedef(typdef));
+ return resolveTypedef(typdef);
}
compiler.unimplemented(element, "resolve($element)");
@@ -547,15 +543,10 @@ class ResolverTask extends CompilerTask {
});
}
- /// Creates a [ResolverVisitor] for resolving an AST in context of [element].
- /// If [useEnclosingScope] is `true` then the initial scope of the visitor
- /// does not include inner scope of [element].
- ///
/// This method should only be used by this library (or tests of
/// this library).
- ResolverVisitor visitorFor(Element element, {bool useEnclosingScope: false}) {
- return new ResolverVisitor(compiler, element,
- _ensureTreeElements(element), useEnclosingScope: useEnclosingScope);
+ ResolverVisitor visitorFor(Element element) {
+ return new ResolverVisitor(compiler, element, _ensureTreeElements(element));
}
TreeElements resolveField(VariableElementX element) {
@@ -1194,18 +1185,20 @@ class ResolverTask extends CompilerTask {
annotation.resolutionState = STATE_STARTED;
Node node = annotation.parseNode(compiler);
+ // TODO(johnniwinther): Find the right analyzable element to hold the
+ // [TreeElements] for the annotation.
Element annotatedElement = annotation.annotatedElement;
- AnalyzableElement context = annotatedElement.analyzableElement;
- assert(invariant(node, context != null,
- message: "No context found for metadata annotation "
- "on $annotatedElement."));
- ResolverVisitor visitor = visitorFor(context, useEnclosingScope: true);
+ Element context = annotatedElement.enclosingElement;
+ if (context == null) {
+ context = annotatedElement;
+ }
+ ResolverVisitor visitor = visitorFor(context);
node.accept(visitor);
annotation.value =
constantCompiler.compileMetadata(annotation, node, visitor.mapping);
// TODO(johnniwinther): Register the relation between the annotation
- // and the annotated element instead. This will allow the backend to
- // retrieve the backend constant and only register metadata on the
+ // and the annotated element instead. This will allow the backed to
+ // retrieve the backend constant and only registered metadata on the
// elements for which it is needed. (Issue 17732).
compiler.backend.registerMetadataConstant(
annotation.value, visitor.mapping);
@@ -2010,8 +2003,7 @@ class ResolverVisitor extends MappingVisitor<Element> {
ResolverVisitor(Compiler compiler,
Element element,
- TreeElementMapping mapping,
- {bool useEnclosingScope: false})
+ TreeElementMapping mapping)
: this.enclosingElement = element,
// When the element is a field, we are actually resolving its
// initial value, which should not have access to instance
@@ -2021,8 +2013,7 @@ class ResolverVisitor extends MappingVisitor<Element> {
this.currentClass = element.isMember ? element.enclosingClass
: null,
this.statementScope = new StatementScope(),
- scope = useEnclosingScope
- ? Scope.buildEnclosingScope(element) : element.buildScope(),
+ scope = element.buildScope(),
// The type annotations on a typedef do not imply type checks.
// TODO(karlklose): clean this up (dartbug.com/8870).
inCheckContext = compiler.enableTypeAssertions &&
@@ -4666,14 +4657,14 @@ Element lookupInScope(Compiler compiler, Node node,
return Elements.unwrap(scope.lookup(name), compiler, node);
}
-TreeElements _ensureTreeElements(AnalyzableElementX element) {
+TreeElements _ensureTreeElements(AnalyzableElement element) {
if (element._treeElements == null) {
element._treeElements = new TreeElementMapping(element);
}
return element._treeElements;
}
-abstract class AnalyzableElementX implements AnalyzableElement {
+abstract class AnalyzableElement implements Element {
TreeElements _treeElements;
bool get hasTreeElements => _treeElements != null;
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698