OLD | NEW |
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 library universe; | 5 library universe; |
6 | 6 |
7 import '../closure.dart'; | 7 import '../closure.dart'; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 import '../dart2jslib.dart'; | 9 import '../dart2jslib.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 selector.namedArguments) { | 446 selector.namedArguments) { |
447 // Invariant: Typed selector can not be based on a malformed type. | 447 // Invariant: Typed selector can not be based on a malformed type. |
448 assert(!identical(receiverType.kind, TypeKind.MALFORMED_TYPE)); | 448 assert(!identical(receiverType.kind, TypeKind.MALFORMED_TYPE)); |
449 } | 449 } |
450 | 450 |
451 /** | 451 /** |
452 * Check if [element] will be the one used at runtime when being | 452 * Check if [element] will be the one used at runtime when being |
453 * invoked on an instance of [cls]. | 453 * invoked on an instance of [cls]. |
454 */ | 454 */ |
455 bool hasElementIn(ClassElement cls, Element element) { | 455 bool hasElementIn(ClassElement cls, Element element) { |
456 Element resolved = cls.lookupMember(element.name); | 456 // Use the selector for the lookup instead of [:element.name:] |
457 if (identical(resolved, element)) return true; | 457 // because the selector has the right privacy information. |
| 458 Element resolved = cls.lookupSelector(this); |
| 459 if (resolved == element) return true; |
458 if (resolved == null) return false; | 460 if (resolved == null) return false; |
459 if (identical(resolved.kind, ElementKind.ABSTRACT_FIELD)) { | 461 if (resolved.isAbstractField()) { |
460 AbstractFieldElement field = resolved; | 462 AbstractFieldElement field = resolved; |
461 if (identical(element, field.getter) || identical(element, field.setter))
{ | 463 if (element == field.getter || element == field.setter) { |
462 return true; | 464 return true; |
463 } else { | 465 } else { |
464 ClassElement otherCls = field.getEnclosingClass(); | 466 ClassElement otherCls = field.getEnclosingClass(); |
465 // We have not found a match, but another class higher in the | 467 // We have not found a match, but another class higher in the |
466 // hierarchy may define the getter or the setter. | 468 // hierarchy may define the getter or the setter. |
467 return hasElementIn(otherCls.superclass, element); | 469 return hasElementIn(otherCls.superclass, element); |
468 } | 470 } |
469 } | 471 } |
470 return false; | 472 return false; |
471 } | 473 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 ClassElement cls = self; | 506 ClassElement cls = self; |
505 if (cls.isSubclassOf(other)) { | 507 if (cls.isSubclassOf(other)) { |
506 // Resolve an invocation of [element.name] on [self]. If it | 508 // Resolve an invocation of [element.name] on [self]. If it |
507 // is found, this selector is a candidate. | 509 // is found, this selector is a candidate. |
508 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 510 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
509 } | 511 } |
510 | 512 |
511 return false; | 513 return false; |
512 } | 514 } |
513 } | 515 } |
OLD | NEW |