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

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

Issue 10575033: Implement override checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix problem that caused an assertion failure (and revert of the first attempt) Created 8 years, 6 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 | « dart/lib/compiler/implementation/dart2js.dart ('k') | dart/lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/elements/elements.dart
diff --git a/dart/lib/compiler/implementation/elements/elements.dart b/dart/lib/compiler/implementation/elements/elements.dart
index 1878a37c3221e27c4bf750c76444dd147556fd00..0a47eb1e2ec0077dfb98be59d555fcc51cc8570f 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -216,6 +216,8 @@ class Element implements Hashable {
bool _isNative = false;
void setNative() { _isNative = true; }
bool isNative() => _isNative;
+
+ FunctionElement asFunctionElement() => null;
}
class ContainerElement extends Element {
@@ -252,12 +254,12 @@ class ContainerElement extends Element {
}
} else {
AbstractFieldElement field = new AbstractFieldElement(element.name, this);
- addMember(field, listener);
if (element.kind == ElementKind.GETTER) {
field.getter = element;
} else {
field.setter = element;
}
+ addMember(field, listener);
}
}
}
@@ -502,11 +504,9 @@ class ForeignElement extends Element {
class AbstractFieldElement extends Element {
FunctionElement getter;
FunctionElement setter;
- Modifiers modifiers;
AbstractFieldElement(SourceString name, Element enclosing)
- : super(name, ElementKind.ABSTRACT_FIELD, enclosing),
- modifiers = new Modifiers.empty();
+ : super(name, ElementKind.ABSTRACT_FIELD, enclosing);
Type computeType(Compiler compiler) {
throw "internal error: AbstractFieldElement has no type";
@@ -526,11 +526,23 @@ class AbstractFieldElement extends Element {
// the compilation unit of the abstract element.
if (getter !== null && getter.enclosingElement === enclosingElement) {
return getter.position();
- } else if (setter != null) {
- // TODO(ahe): checking for null should not be necessary.
+ } else {
return setter.position();
}
}
+
+ Modifiers get modifiers() {
+ // The resolver ensures that the flags match (ignoring abstract).
+ if (getter !== null) {
+ return new Modifiers.withFlags(
+ getter.modifiers.nodes,
+ getter.modifiers.flags | Modifiers.FLAG_ABSTRACT);
+ } else {
+ return new Modifiers.withFlags(
+ setter.modifiers.nodes,
+ setter.modifiers.flags | Modifiers.FLAG_ABSTRACT);
+ }
+ }
}
class FunctionSignature {
@@ -642,6 +654,8 @@ class FunctionElement extends Element {
Node parseNode(DiagnosticListener listener) => cachedNode;
Token position() => cachedNode.getBeginToken();
+
+ FunctionElement asFunctionElement() => this;
}
class ConstructorBodyElement extends FunctionElement {
@@ -735,12 +749,7 @@ class ClassElement extends ContainerElement {
}
ClassElement ensureResolved(Compiler compiler) {
- if (!isResolved && !isBeingResolved) {
- isBeingResolved = true;
- compiler.resolveClass(this);
- isBeingResolved = false;
- isResolved = true;
- }
+ compiler.resolveClass(this);
return this;
}
@@ -756,11 +765,12 @@ class ClassElement extends ContainerElement {
Element lookupSuperMember(SourceString memberName) {
for (ClassElement s = superclass; s != null; s = s.superclass) {
Element e = s.lookupLocalMember(memberName);
- if (e !== null) {
- if (!memberName.isPrivate() || getLibrary() === e.getLibrary()) {
- return e;
- }
- }
+ if (e === null) continue;
+ // Private members from a different library are not visible.
+ if (memberName.isPrivate() && getLibrary() !== e.getLibrary()) continue;
+ // Static members are not inherited.
+ if (e.modifiers.isStatic()) continue;
+ return e;
}
return null;
}
« no previous file with comments | « dart/lib/compiler/implementation/dart2js.dart ('k') | dart/lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698