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

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

Issue 10837140: Make addGetterOrSetter (now: defineAccessor) not add the abstract field as a member. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleaner validation of member accessors. Created 8 years, 4 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 | « lib/compiler/implementation/elements/elements.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index bcd63bb596299f64a75eed2676ce93086146c91e..fe7e42d66844b125e97ed666464f8674c5cb90c3 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -279,20 +279,36 @@ class ResolverTask extends CompilerTask {
}
void checkAbstractField(Element member) {
- if (member is !AbstractFieldElement) return;
- if (member.getter === null) return;
- if (member.setter === null) return;
- int getterFlags = member.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
- int setterFlags = member.setter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
+ // Only check for getters. The test can only fail if there is both a setter
+ // and a getter with the same name, and we only need to check each abstract
+ // field once, so we just ignore setters.
+ if (!member.isGetter()) return;
+
+ // Find the associated abstract field.
+ ClassElement classElement = member.getEnclosingClass();
+ Element lookupElement = classElement.lookupLocalMember(member.name);
+ if (lookupElement === null) {
+ compiler.internalErrorOnElement(member,
+ "No abstract field for accessor");
+ } else if (lookupElement.kind !== ElementKind.ABSTRACT_FIELD) {
+ compiler.internalErrorOnElement(
+ member, "Inaccessible abstract field for accessor");
+ }
+ AbstractFieldElement field = lookupElement;
+
+ if (field.getter === null) return;
+ if (field.setter === null) return;
+ int getterFlags = field.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
+ int setterFlags = field.setter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
if (getterFlags !== setterFlags) {
final mismatchedFlags =
new Modifiers.withFlags(null, getterFlags ^ setterFlags);
compiler.reportMessage(
- compiler.spanFromElement(member.getter),
+ compiler.spanFromElement(field.getter),
MessageKind.GETTER_MISMATCH.error([mismatchedFlags]),
api.Diagnostic.ERROR);
compiler.reportMessage(
- compiler.spanFromElement(member.setter),
+ compiler.spanFromElement(field.setter),
MessageKind.SETTER_MISMATCH.error([mismatchedFlags]),
api.Diagnostic.ERROR);
}
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698