| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 final TypeMask mask; | 452 final TypeMask mask; |
| 453 | 453 |
| 454 TypedSelector(this.mask, Selector selector) | 454 TypedSelector(this.mask, Selector selector) |
| 455 : asUntyped = selector.asUntyped, | 455 : asUntyped = selector.asUntyped, |
| 456 super(selector.kind, | 456 super(selector.kind, |
| 457 selector.name, | 457 selector.name, |
| 458 selector.library, | 458 selector.library, |
| 459 selector.argumentCount, | 459 selector.argumentCount, |
| 460 selector.namedArguments) { | 460 selector.namedArguments) { |
| 461 // Invariant: Typed selector can not be based on a malformed type. | 461 // Invariant: Typed selector can not be based on a malformed type. |
| 462 assert(!identical(mask.base.kind, TypeKind.MALFORMED_TYPE)); | 462 assert(mask.isEmpty || !identical(mask.base.kind, TypeKind.MALFORMED_TYPE)); |
| 463 assert(asUntyped.mask == null); | 463 assert(asUntyped.mask == null); |
| 464 } | 464 } |
| 465 | 465 |
| 466 TypedSelector.exact(DartType base, Selector selector) | 466 TypedSelector.exact(DartType base, Selector selector) |
| 467 : this(new TypeMask.exact(base), selector); | 467 : this(new TypeMask.exact(base), selector); |
| 468 | 468 |
| 469 TypedSelector.subclass(DartType base, Selector selector) | 469 TypedSelector.subclass(DartType base, Selector selector) |
| 470 : this(new TypeMask.subclass(base), selector); | 470 : this(new TypeMask.subclass(base), selector); |
| 471 | 471 |
| 472 TypedSelector.subtype(DartType base, Selector selector) | 472 TypedSelector.subtype(DartType base, Selector selector) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 497 // A closure can be called through any typed selector: | 497 // A closure can be called through any typed selector: |
| 498 // class A { | 498 // class A { |
| 499 // get foo => () => 42; | 499 // get foo => () => 42; |
| 500 // bar() => foo(); // The call to 'foo' is a typed selector. | 500 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 501 // } | 501 // } |
| 502 ClassElement other = element.getEnclosingClass(); | 502 ClassElement other = element.getEnclosingClass(); |
| 503 if (identical(other.superclass, compiler.closureClass)) { | 503 if (identical(other.superclass, compiler.closureClass)) { |
| 504 return appliesUntyped(element, compiler); | 504 return appliesUntyped(element, compiler); |
| 505 } | 505 } |
| 506 | 506 |
| 507 if (mask.isEmpty) { |
| 508 if (!mask.isNullable) return false; |
| 509 return hasElementIn(compiler.backend.jsNullClass, element) |
| 510 && appliesUntyped(element, compiler); |
| 511 } |
| 512 |
| 507 // TODO(kasperl): Can't we just avoid creating typed selectors | 513 // TODO(kasperl): Can't we just avoid creating typed selectors |
| 508 // based of function types? | 514 // based of function types? |
| 509 Element self = mask.base.element; | 515 Element self = mask.base.element; |
| 510 if (self.isTypedef()) { | 516 if (self.isTypedef()) { |
| 511 // A typedef is a function type that doesn't have any | 517 // A typedef is a function type that doesn't have any |
| 512 // user-defined members. | 518 // user-defined members. |
| 513 return false; | 519 return false; |
| 514 } | 520 } |
| 515 | 521 |
| 516 if (mask.isNullable && compiler.backend.isNullImplementation(other)) { | 522 if (mask.isNullable && compiler.backend.isNullImplementation(other)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 536 ClassElement cls = self; | 542 ClassElement cls = self; |
| 537 if (cls.isSubclassOf(other)) { | 543 if (cls.isSubclassOf(other)) { |
| 538 // Resolve an invocation of [element.name] on [self]. If it | 544 // Resolve an invocation of [element.name] on [self]. If it |
| 539 // is found, this selector is a candidate. | 545 // is found, this selector is a candidate. |
| 540 return hasElementIn(cls, element) && appliesUntyped(element, compiler); | 546 return hasElementIn(cls, element) && appliesUntyped(element, compiler); |
| 541 } | 547 } |
| 542 } | 548 } |
| 543 return false; | 549 return false; |
| 544 } | 550 } |
| 545 } | 551 } |
| OLD | NEW |