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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 checkMembers(ClassElement cls) { 248 checkMembers(ClassElement cls) {
249 if (cls === compiler.objectClass) return; 249 if (cls === compiler.objectClass) return;
250 cls.forEachMember((holder, member) { 250 cls.forEachMember((holder, member) {
251 checkAbstractField(member); 251 checkAbstractField(member);
252 checkValidOverride(member, cls.lookupSuperMember(member.name)); 252 checkValidOverride(member, cls.lookupSuperMember(member.name));
253 }); 253 });
254 } 254 }
255 255
256 void checkAbstractField(Element member) { 256 void checkAbstractField(Element member) {
257 if (member is !AbstractFieldElement) return; 257 // Only check for getters. The test can only fail if there is both a setter
258 if (member.getter === null) return; 258 // and a getter with the same name, and we only need to check each abstract
259 if (member.setter === null) return; 259 // field once, so we just ignore setters.
260 int getterFlags = member.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT; 260 if (!member.isGetter()) return;
261 int setterFlags = member.setter.modifiers.flags | Modifiers.FLAG_ABSTRACT; 261
262 // Find the associated abstract field.
263 AbstractFieldElement field;
264 ClassElement outerClass = member.getEnclosingClass();
265 if (outerClass != null) {
266 Element element = outerClass.lookupLocalMember(member.name);
267 // This is wrong, but can currently happen. See, e.g., the test
268 // language/field2_negative_test where we are OK on failing.
269 if (element.kind !== ElementKind.ABSTRACT_FIELD) return;
Anders Johnsen 2012/08/07 13:02:30 Returning here looks wrong, turn comment into TODO
ahe 2012/08/10 11:21:46 Please report the error. You have fixed a bug in d
Lasse Reichstein Nielsen 2012/08/13 13:37:51 Perhaps. It seems we continue compiling even if we
ahe 2012/08/13 16:20:27 Could please provide an example that illustrates w
Lasse Reichstein Nielsen 2012/08/14 11:41:07 Should happen for, e.g.: class A { extern
270 field = element;
271 } else {
272 LibraryElement library = member.getLibrary();
273 field = library.findLocal(member.name);
274 }
Anders Johnsen 2012/08/07 13:02:30 assert field !== null?
ahe 2012/08/10 11:21:46 Better to use internalErrorOnElement.
Lasse Reichstein Nielsen 2012/08/13 13:37:51 Done.
275
276 if (field.getter === null) return;
277 if (field.setter === null) return;
278 int getterFlags = field.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
279 int setterFlags = field.setter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
262 if (getterFlags !== setterFlags) { 280 if (getterFlags !== setterFlags) {
263 final mismatchedFlags = 281 final mismatchedFlags =
264 new Modifiers.withFlags(null, getterFlags ^ setterFlags); 282 new Modifiers.withFlags(null, getterFlags ^ setterFlags);
265 compiler.reportMessage( 283 compiler.reportMessage(
266 compiler.spanFromElement(member.getter), 284 compiler.spanFromElement(field.getter),
267 MessageKind.GETTER_MISMATCH.error([mismatchedFlags]), 285 MessageKind.GETTER_MISMATCH.error([mismatchedFlags]),
268 api.Diagnostic.ERROR); 286 api.Diagnostic.ERROR);
269 compiler.reportMessage( 287 compiler.reportMessage(
270 compiler.spanFromElement(member.setter), 288 compiler.spanFromElement(field.setter),
271 MessageKind.SETTER_MISMATCH.error([mismatchedFlags]), 289 MessageKind.SETTER_MISMATCH.error([mismatchedFlags]),
272 api.Diagnostic.ERROR); 290 api.Diagnostic.ERROR);
273 } 291 }
274 } 292 }
275 293
276 reportErrorWithContext(Element errorneousElement, 294 reportErrorWithContext(Element errorneousElement,
277 MessageKind errorMessage, 295 MessageKind errorMessage,
278 Element contextElement, 296 Element contextElement,
279 MessageKind contextMessage) { 297 MessageKind contextMessage) {
280 compiler.reportMessage( 298 compiler.reportMessage(
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 TopScope(LibraryElement library) : super(null, library); 2319 TopScope(LibraryElement library) : super(null, library);
2302 Element lookup(SourceString name) { 2320 Element lookup(SourceString name) {
2303 return library.find(name); 2321 return library.find(name);
2304 } 2322 }
2305 2323
2306 Element add(Element newElement) { 2324 Element add(Element newElement) {
2307 throw "Cannot add an element in the top scope"; 2325 throw "Cannot add an element in the top scope";
2308 } 2326 }
2309 String toString() => '$element'; 2327 String toString() => '$element';
2310 } 2328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698