Chromium Code Reviews| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 selector.namedArguments) { | 423 selector.namedArguments) { |
| 424 // Invariant: Typed selector can not be based on a malformed type. | 424 // Invariant: Typed selector can not be based on a malformed type. |
| 425 assert(!identical(receiverType.kind, TypeKind.MALFORMED_TYPE)); | 425 assert(!identical(receiverType.kind, TypeKind.MALFORMED_TYPE)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 /** | 428 /** |
| 429 * Check if [element] will be the one used at runtime when being | 429 * Check if [element] will be the one used at runtime when being |
| 430 * invoked on an instance of [cls]. | 430 * invoked on an instance of [cls]. |
| 431 */ | 431 */ |
| 432 bool hasElementIn(ClassElement cls, Element element) { | 432 bool hasElementIn(ClassElement cls, Element element) { |
| 433 Element resolved = cls.lookupMember(element.name); | 433 // Use the selector for the lookup instead of [:element.name:] |
| 434 if (identical(resolved, element)) return true; | 434 // because the selector has the right privacy information. |
| 435 if (resolved == null) return false; | 435 Element resolved = cls.lookupSelector(this); |
| 436 if (identical(resolved.kind, ElementKind.ABSTRACT_FIELD)) { | 436 if (resolved == element) return true; |
| 437 if (resolved == null) return ; | |
|
Johnni Winther
2013/02/05 11:07:35
Why not return false here?
ngeoffray
2013/02/05 11:17:30
Bad edit. Thanks for spotting it!
| |
| 438 if (resolved.isAbstractField()) { | |
| 437 AbstractFieldElement field = resolved; | 439 AbstractFieldElement field = resolved; |
| 438 if (identical(element, field.getter) || identical(element, field.setter)) { | 440 if (element == field.getter || element == field.setter) { |
| 439 return true; | 441 return true; |
| 440 } else { | 442 } else { |
| 441 ClassElement otherCls = field.getEnclosingClass(); | 443 ClassElement otherCls = field.getEnclosingClass(); |
| 442 // We have not found a match, but another class higher in the | 444 // We have not found a match, but another class higher in the |
| 443 // hierarchy may define the getter or the setter. | 445 // hierarchy may define the getter or the setter. |
| 444 return hasElementIn(otherCls.superclass, element); | 446 return hasElementIn(otherCls.superclass, element); |
| 445 } | 447 } |
| 446 } | 448 } |
| 447 return false; | 449 return false; |
| 448 } | 450 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 ClassElement cls = self; | 482 ClassElement cls = self; |
| 481 if (cls.isSubclassOf(other)) { | 483 if (cls.isSubclassOf(other)) { |
| 482 // Resolve an invocation of [element.name] on [self]. If it | 484 // Resolve an invocation of [element.name] on [self]. If it |
| 483 // is found, this selector is a candidate. | 485 // is found, this selector is a candidate. |
| 484 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 486 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 485 } | 487 } |
| 486 | 488 |
| 487 return false; | 489 return false; |
| 488 } | 490 } |
| 489 } | 491 } |
| OLD | NEW |