| 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 final Selector asUntyped; | 416 final Selector asUntyped; |
| 417 final TypeMask mask; | 417 final TypeMask mask; |
| 418 | 418 |
| 419 TypedSelector(this.mask, Selector selector) | 419 TypedSelector(this.mask, Selector selector) |
| 420 : asUntyped = selector.asUntyped, | 420 : asUntyped = selector.asUntyped, |
| 421 super(selector.kind, | 421 super(selector.kind, |
| 422 selector.name, | 422 selector.name, |
| 423 selector.library, | 423 selector.library, |
| 424 selector.argumentCount, | 424 selector.argumentCount, |
| 425 selector.namedArguments) { | 425 selector.namedArguments) { |
| 426 // Invariant: Typed selector can not be based on a malformed type. | |
| 427 assert(mask.isEmpty || !identical(mask.base.kind, TypeKind.MALFORMED_TYPE)); | |
| 428 assert(asUntyped.mask == null); | 426 assert(asUntyped.mask == null); |
| 429 } | 427 } |
| 430 | 428 |
| 431 TypedSelector.exact(DartType base, Selector selector) | 429 TypedSelector.exact(DartType base, Selector selector) |
| 432 : this(new TypeMask.exact(base), selector); | 430 : this(new TypeMask.exact(base), selector); |
| 433 | 431 |
| 434 TypedSelector.subclass(DartType base, Selector selector) | 432 TypedSelector.subclass(DartType base, Selector selector) |
| 435 : this(new TypeMask.subclass(base), selector); | 433 : this(new TypeMask.subclass(base), selector); |
| 436 | 434 |
| 437 TypedSelector.subtype(DartType base, Selector selector) | 435 TypedSelector.subtype(DartType base, Selector selector) |
| 438 : this(new TypeMask.subtype(base), selector); | 436 : this(new TypeMask.subtype(base), selector); |
| 439 | 437 |
| 440 bool get hasExactMask => mask.isExact; | |
| 441 | 438 |
| 442 bool appliesUnnamed(Element element, Compiler compiler) { | 439 bool appliesUnnamed(Element element, Compiler compiler) { |
| 443 assert(sameNameHack(element, compiler)); | 440 assert(sameNameHack(element, compiler)); |
| 444 // [TypedSelector] are only used after resolution. | 441 // [TypedSelector] are only used after resolution. |
| 445 assert(compiler.phase > Compiler.PHASE_RESOLVING); | 442 assert(compiler.phase > Compiler.PHASE_RESOLVING); |
| 446 if (!element.isMember()) return false; | 443 if (!element.isMember()) return false; |
| 447 | 444 |
| 448 // A closure can be called through any typed selector: | 445 // A closure can be called through any typed selector: |
| 449 // class A { | 446 // class A { |
| 450 // get foo => () => 42; | 447 // get foo => () => 42; |
| 451 // bar() => foo(); // The call to 'foo' is a typed selector. | 448 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 452 // } | 449 // } |
| 453 if (element.getEnclosingClass().isClosure()) { | 450 if (element.getEnclosingClass().isClosure()) { |
| 454 return appliesUntyped(element, compiler); | 451 return appliesUntyped(element, compiler); |
| 455 } | 452 } |
| 456 | 453 |
| 457 if (!mask.canHit(element, this, compiler)) return false; | 454 if (!mask.canHit(element, this, compiler)) return false; |
| 458 return appliesUntyped(element, compiler); | 455 return appliesUntyped(element, compiler); |
| 459 } | 456 } |
| 460 } | 457 } |
| OLD | NEW |