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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 296463003: Handle metadata on nested function parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment. 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/elements/modelx.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index 03224a3d8cc781a45d228d63854b02fd2770ed87..3770c6f21464612cc05eef8ec2f536d1fdb8071d 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -61,7 +61,7 @@ abstract class ElementX extends Element {
return null;
}
- void addMetadata(MetadataAnnotation annotation) {
+ void addMetadata(MetadataAnnotationX annotation) {
assert(annotation.annotatedElement == null);
annotation.annotatedElement = this;
addMetadataInternal(annotation);
@@ -202,6 +202,9 @@ abstract class ElementX extends Element {
Element get outermostEnclosingMemberOrTopLevel {
// TODO(lrn): Why is this called "Outermost"?
+ // TODO(johnniwinther): Clean up this method: This method does not return
+ // the outermost for elements in closure classses, but some call-sites rely
+ // on that behavior.
for (Element e = this; e != null; e = e.enclosingElement) {
if (e.isMember || e.isTopLevel) {
return e;
@@ -262,7 +265,9 @@ abstract class ElementX extends Element {
void diagnose(Element context, DiagnosticListener listener) {}
- TreeElements get treeElements => enclosingElement.treeElements;
+ TreeElements get treeElements => analyzableElement.treeElements;
+
+ AnalyzableElement get analyzableElement => outermostEnclosingMemberOrTopLevel;
}
/**
@@ -543,7 +548,7 @@ class ScopeX {
}
}
-class CompilationUnitElementX extends ElementX with AnalyzableElement
+class CompilationUnitElementX extends ElementX
implements CompilationUnitElement {
final Script script;
PartOf partTag;
@@ -612,6 +617,8 @@ class CompilationUnitElementX extends ElementX with AnalyzableElement
return '${script.readableUri}'.compareTo('${other.script.readableUri}');
}
+ Element get analyzableElement => library;
+
accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this);
}
@@ -723,7 +730,7 @@ class ImportScope {
}
class LibraryElementX
- extends ElementX with AnalyzableElement, PatchMixin<LibraryElementX>
+ extends ElementX with AnalyzableElementX, PatchMixin<LibraryElementX>
implements LibraryElement {
final Uri canonicalUri;
CompilationUnitElement entryCompilationUnit;
@@ -774,6 +781,8 @@ class LibraryElementX
CompilationUnitElement get compilationUnit => entryCompilationUnit;
+ Element get analyzableElement => this;
+
void addCompilationUnit(CompilationUnitElement element) {
compilationUnits = compilationUnits.prepend(element);
}
@@ -1008,7 +1017,7 @@ class PrefixElementX extends ElementX implements PrefixElement {
}
class TypedefElementX extends ElementX
- with AnalyzableElement, TypeDeclarationElementX<TypedefType>
+ with AnalyzableElementX, TypeDeclarationElementX<TypedefType>
implements TypedefElement {
Typedef cachedNode;
@@ -1020,7 +1029,7 @@ class TypedefElementX extends ElementX
/// [:true:] if the typedef has been checked for cyclic reference.
bool hasBeenCheckedForCycles = false;
- bool get isResolved => hasTreeElements;
+ int resolutionState = STATE_NOT_STARTED;
TypedefElementX(String name, Element enclosing)
: super(name, ElementKind.TYPEDEF, enclosing);
@@ -1045,10 +1054,16 @@ class TypedefElementX extends ElementX
if (thisTypeCache != null) return thisTypeCache;
Typedef node = parseNode(compiler);
setThisAndRawTypes(compiler, createTypeVariables(node.typeParameters));
- compiler.resolveTypedef(this);
+ ensureResolved(compiler);
return thisTypeCache;
}
+ void ensureResolved(Compiler compiler) {
+ if (resolutionState == STATE_NOT_STARTED) {
+ compiler.resolver.resolve(this);
+ }
+ }
+
TypedefType createType(Link<DartType> typeArguments) {
return new TypedefType(this, typeArguments);
}
@@ -1091,7 +1106,7 @@ class VariableList {
DartType computeType(Element element, Compiler compiler) => type;
}
-class VariableElementX extends ElementX with AnalyzableElement
+class VariableElementX extends ElementX with AnalyzableElementX
implements VariableElement {
final Token token;
final VariableList variables;
@@ -1447,7 +1462,7 @@ class FunctionSignatureX implements FunctionSignature {
}
abstract class FunctionElementX
- extends ElementX with AnalyzableElement, PatchMixin<FunctionElement>
+ extends ElementX with AnalyzableElementX, PatchMixin<FunctionElement>
implements FunctionElement {
DartType typeCache;
final Modifiers modifiers;
@@ -1809,10 +1824,12 @@ abstract class TypeDeclarationElementX<T extends GenericType>
}
return arguments.toLink();
}
+
+ bool get isResolved => resolutionState == STATE_DONE;
}
abstract class BaseClassElementX extends ElementX
- with AnalyzableElement,
+ with AnalyzableElementX,
TypeDeclarationElementX<InterfaceType>,
PatchMixin<ClassElement>,
ClassMemberMixin
@@ -1824,7 +1841,6 @@ abstract class BaseClassElementX extends ElementX
String nativeTagInfo;
int supertypeLoadState;
int resolutionState;
- bool get isResolved => resolutionState == STATE_DONE;
bool isProxy = false;
bool hasIncompleteHierarchy = false;

Powered by Google App Engine
This is Rietveld 408576698