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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 // class A { | 519 // class A { |
| 520 // get foo => () => 42; | 520 // get foo => () => 42; |
| 521 // bar() => foo(); // The call to 'foo' is a typed selector. | 521 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 522 // } | 522 // } |
| 523 ClassElement other = element.getEnclosingClass(); | 523 ClassElement other = element.getEnclosingClass(); |
| 524 if (identical(other.superclass, compiler.closureClass)) { | 524 if (identical(other.superclass, compiler.closureClass)) { |
| 525 return appliesUntyped(element, compiler); | 525 return appliesUntyped(element, compiler); |
| 526 } | 526 } |
| 527 | 527 |
| 528 ClassElement self = receiverType.element; | 528 ClassElement self = receiverType.element; |
| 529 if (other.implementsInterface(self) || other.isSubclassOf(self)) { | 529 |
| 530 // Checks if a subclass of [superClass] implements [self]. If one | |
| 531 // is found, [element] is a candidate. | |
| 532 bool hasOneSubclassThatImplements(ClassElement superClass) { | |
|
ahe
2012/10/29 13:15:21
superclass is one word.
ngeoffray
2012/10/29 13:35:18
Done.
| |
| 533 // [TypedSelector] are only used when compiling. | |
| 534 assert(compiler.phase == Compiler.PHASE_COMPILING); | |
| 535 Set<ClassElement> typesImplementedBySubclasses = | |
| 536 compiler.world.typesImplementedBySubclasses[superClass]; | |
|
ahe
2012/10/29 13:15:21
I'm concerned by the direct use of maps. Could you
ngeoffray
2012/10/29 13:35:18
Done.
| |
| 537 if (typesImplementedBySubclasses == null) return false; | |
| 538 return typesImplementedBySubclasses.contains(receiverType); | |
| 539 } | |
| 540 | |
| 541 if (other.implementsInterface(self) | |
| 542 || other.isSubclassOf(self) | |
| 543 || hasOneSubclassThatImplements(other)) { | |
| 530 return appliesUntyped(element, compiler); | 544 return appliesUntyped(element, compiler); |
| 531 } | 545 } |
| 532 | 546 |
| 533 if (!self.isInterface() && self.isSubclassOf(other)) { | 547 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 534 // Resolve an invocation of [element.name] on [self]. If it | 548 // Resolve an invocation of [element.name] on [self]. If it |
| 535 // is found, this selector is a candidate. | 549 // is found, this selector is a candidate. |
| 536 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 550 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 537 } | 551 } |
| 538 | 552 |
| 539 return false; | 553 return false; |
| 540 } | 554 } |
| 541 } | 555 } |
| OLD | NEW |