| 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 /** | 477 /** |
| 478 * Check if [element] will be the one used at runtime when being | 478 * Check if [element] will be the one used at runtime when being |
| 479 * invoked on an instance of [cls]. | 479 * invoked on an instance of [cls]. |
| 480 */ | 480 */ |
| 481 bool hasElementIn(ClassElement cls, Element element) { | 481 bool hasElementIn(ClassElement cls, Element element) { |
| 482 return cls.lookupSelector(this) == element; | 482 return cls.lookupSelector(this) == element; |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool appliesUnnamed(Element element, Compiler compiler) { | 485 bool appliesUnnamed(Element element, Compiler compiler) { |
| 486 assert(sameNameHack(element, compiler)); | 486 assert(sameNameHack(element, compiler)); |
| 487 // [TypedSelector] are only used when compiling. | 487 // [TypedSelector] are only used after resolution. |
| 488 assert(compiler.phase == Compiler.PHASE_COMPILING); | 488 assert(compiler.phase > Compiler.PHASE_RESOLVING); |
| 489 if (!element.isMember()) return false; | 489 if (!element.isMember()) return false; |
| 490 | 490 |
| 491 // A closure can be called through any typed selector: | 491 // A closure can be called through any typed selector: |
| 492 // class A { | 492 // class A { |
| 493 // get foo => () => 42; | 493 // get foo => () => 42; |
| 494 // bar() => foo(); // The call to 'foo' is a typed selector. | 494 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 495 // } | 495 // } |
| 496 ClassElement other = element.getEnclosingClass(); | 496 ClassElement other = element.getEnclosingClass(); |
| 497 if (identical(other.superclass, compiler.closureClass)) { | 497 if (identical(other.superclass, compiler.closureClass)) { |
| 498 return appliesUntyped(element, compiler); | 498 return appliesUntyped(element, compiler); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 ClassElement cls = self; | 530 ClassElement cls = self; |
| 531 if (cls.isSubclassOf(other)) { | 531 if (cls.isSubclassOf(other)) { |
| 532 // Resolve an invocation of [element.name] on [self]. If it | 532 // Resolve an invocation of [element.name] on [self]. If it |
| 533 // is found, this selector is a candidate. | 533 // is found, this selector is a candidate. |
| 534 return hasElementIn(cls, element) && appliesUntyped(element, compiler); | 534 return hasElementIn(cls, element) && appliesUntyped(element, compiler); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 return false; | 537 return false; |
| 538 } | 538 } |
| 539 } | 539 } |
| OLD | NEW |