| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 ClassElement otherCls = field.getEnclosingClass(); | 400 ClassElement otherCls = field.getEnclosingClass(); |
| 401 // We have not found a match, but another class higher in the | 401 // We have not found a match, but another class higher in the |
| 402 // hierarchy may define the getter or the setter. | 402 // hierarchy may define the getter or the setter. |
| 403 return hasElementIn(otherCls.superclass, element); | 403 return hasElementIn(otherCls.superclass, element); |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 return false; | 406 return false; |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool applies(Element element, Compiler compiler) { | 409 bool applies(Element element, Compiler compiler) { |
| 410 // [TypedSelector] are only used when compiling. |
| 411 assert(compiler.phase == Compiler.PHASE_COMPILING); |
| 410 if (!element.isMember()) return false; | 412 if (!element.isMember()) return false; |
| 411 | 413 |
| 412 // A closure can be called through any typed selector: | 414 // A closure can be called through any typed selector: |
| 413 // class A { | 415 // class A { |
| 414 // get foo => () => 42; | 416 // get foo => () => 42; |
| 415 // bar() => foo(); // The call to 'foo' is a typed selector. | 417 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 416 // } | 418 // } |
| 417 ClassElement other = element.getEnclosingClass(); | 419 ClassElement other = element.getEnclosingClass(); |
| 418 if (identical(other.superclass, compiler.closureClass)) { | 420 if (identical(other.superclass, compiler.closureClass)) { |
| 419 return appliesUntyped(element, compiler); | 421 return appliesUntyped(element, compiler); |
| 420 } | 422 } |
| 421 | 423 |
| 422 ClassElement self = receiverType.element; | 424 ClassElement self = receiverType.element; |
| 423 if (other.implementsInterface(self) || other.isSubclassOf(self)) { | 425 |
| 426 if (other.implementsInterface(self) |
| 427 || other.isSubclassOf(self) |
| 428 || compiler.world.hasAnySubclassThatImplements(other, receiverType)) { |
| 424 return appliesUntyped(element, compiler); | 429 return appliesUntyped(element, compiler); |
| 425 } | 430 } |
| 426 | 431 |
| 427 if (!self.isInterface() && self.isSubclassOf(other)) { | 432 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 428 // Resolve an invocation of [element.name] on [self]. If it | 433 // Resolve an invocation of [element.name] on [self]. If it |
| 429 // is found, this selector is a candidate. | 434 // is found, this selector is a candidate. |
| 430 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 435 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 431 } | 436 } |
| 432 | 437 |
| 433 return false; | 438 return false; |
| 434 } | 439 } |
| 435 } | 440 } |
| OLD | NEW |