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 '../runtime_types.dart'; | 10 import '../runtime_types.dart'; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 // class A { | 516 // class A { |
| 517 // get foo => () => 42; | 517 // get foo => () => 42; |
| 518 // bar() => foo(); // The call to 'foo' is a typed selector. | 518 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 519 // } | 519 // } |
| 520 ClassElement other = element.getEnclosingClass(); | 520 ClassElement other = element.getEnclosingClass(); |
| 521 if (identical(other.superclass, compiler.closureClass)) { | 521 if (identical(other.superclass, compiler.closureClass)) { |
| 522 return appliesUntyped(element, compiler); | 522 return appliesUntyped(element, compiler); |
| 523 } | 523 } |
| 524 | 524 |
| 525 ClassElement self = receiverType.element; | 525 ClassElement self = receiverType.element; |
| 526 if (other.implementsInterface(self) || other.isSubclassOf(self)) { | 526 |
| 527 // Checks if a subclass of [superClass] implements [self]. If one | |
| 528 // is found, [element] is a candidate. | |
| 529 bool hasOneSubclassThatImplements(ClassElement superClass) { | |
|
ahe
2012/10/29 06:18:29
Have you measured the compile-time impact of this?
| |
| 530 // [TypedSelector] are only used when compiling. | |
| 531 assert(compiler.phase == Compiler.PHASE_COMPILING); | |
| 532 Set<ClassElement> subclasses = compiler.world.subtypes[superClass]; | |
| 533 if (subclasses == null) return false; | |
| 534 for (ClassElement cls in subclasses) { | |
| 535 if (cls.implementsInterface(self)) return true; | |
| 536 } | |
| 537 return false; | |
| 538 } | |
| 539 | |
| 540 if (other.implementsInterface(self) | |
| 541 || other.isSubclassOf(self) | |
| 542 || hasOneSubclassThatImplements(other)) { | |
| 527 return appliesUntyped(element, compiler); | 543 return appliesUntyped(element, compiler); |
| 528 } | 544 } |
| 529 | 545 |
| 530 if (!self.isInterface() && self.isSubclassOf(other)) { | 546 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 531 // Resolve an invocation of [element.name] on [self]. If it | 547 // Resolve an invocation of [element.name] on [self]. If it |
| 532 // is found, this selector is a candidate. | 548 // is found, this selector is a candidate. |
| 533 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 549 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 534 } | 550 } |
| 535 | 551 |
| 536 return false; | 552 return false; |
| 537 } | 553 } |
| 538 } | 554 } |
| OLD | NEW |