| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(johnniwinther): Temporarily copied from analyzer2dart. Merge when | 5 // TODO(johnniwinther): Temporarily copied from analyzer2dart. Merge when |
| 6 // we shared code with the analyzer and this semantic visitor is complete. | 6 // we shared code with the analyzer and this semantic visitor is complete. |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Code for classifying the semantics of identifiers appearing in a Dart file. | 9 * Code for classifying the semantics of identifiers appearing in a Dart file. |
| 10 */ | 10 */ |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 /// An invocation of an ill-defined redirecting factory constructor. | 468 /// An invocation of an ill-defined redirecting factory constructor. |
| 469 /// | 469 /// |
| 470 /// For instance | 470 /// For instance |
| 471 /// class C { | 471 /// class C { |
| 472 /// factory C() = Unresolved; | 472 /// factory C() = Unresolved; |
| 473 /// } | 473 /// } |
| 474 /// m() => new C(); | 474 /// m() => new C(); |
| 475 /// | 475 /// |
| 476 ERRONEOUS_REDIRECTING_FACTORY, | 476 ERRONEOUS_REDIRECTING_FACTORY, |
| 477 |
| 478 |
| 479 /// An invocation of a constructor with incompatible arguments. |
| 480 /// |
| 481 /// For instance |
| 482 /// class C { |
| 483 /// C(); |
| 484 /// } |
| 485 /// m() => new C(true); |
| 486 /// |
| 487 INCOMPATIBLE, |
| 477 } | 488 } |
| 478 | 489 |
| 479 /// Data structure used to classify the semantics of a constructor invocation. | 490 /// Data structure used to classify the semantics of a constructor invocation. |
| 480 class ConstructorAccessSemantics { | 491 class ConstructorAccessSemantics { |
| 481 /// The kind of constructor invocation. | 492 /// The kind of constructor invocation. |
| 482 final ConstructorAccessKind kind; | 493 final ConstructorAccessKind kind; |
| 483 | 494 |
| 484 /// The invoked constructor. | 495 /// The invoked constructor. |
| 485 final Element element; | 496 final Element element; |
| 486 | 497 |
| 487 /// The type on which the constructor is invoked. | 498 /// The type on which the constructor is invoked. |
| 488 final DartType type; | 499 final DartType type; |
| 489 | 500 |
| 490 ConstructorAccessSemantics(this.kind, this.element, this.type); | 501 ConstructorAccessSemantics(this.kind, this.element, this.type); |
| 491 | 502 |
| 492 /// The effect target of the access. Used to defined redirecting factory | 503 /// The effect target of the access. Used to defined redirecting factory |
| 493 /// constructor invocations. | 504 /// constructor invocations. |
| 494 ConstructorAccessSemantics get effectiveTargetSemantics => this; | 505 ConstructorAccessSemantics get effectiveTargetSemantics => this; |
| 495 | 506 |
| 496 /// `true` if this invocation is erroneous. | 507 /// `true` if this invocation is erroneous. |
| 497 bool get isErroneous { | 508 bool get isErroneous { |
| 498 return kind == ConstructorAccessKind.ABSTRACT || | 509 return kind == ConstructorAccessKind.ABSTRACT || |
| 499 kind == ConstructorAccessKind.UNRESOLVED_TYPE || | 510 kind == ConstructorAccessKind.UNRESOLVED_TYPE || |
| 500 kind == ConstructorAccessKind.UNRESOLVED_CONSTRUCTOR || | 511 kind == ConstructorAccessKind.UNRESOLVED_CONSTRUCTOR || |
| 501 kind == ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR || | 512 kind == ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR || |
| 502 kind == ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY; | 513 kind == ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY || |
| 514 kind == ConstructorAccessKind.INCOMPATIBLE; |
| 503 } | 515 } |
| 516 |
| 517 String toString() => 'ConstructorAccessSemantics($kind, $element, $type)'; |
| 504 } | 518 } |
| 505 | 519 |
| 506 /// Data structure used to classify the semantics of a redirecting factory | 520 /// Data structure used to classify the semantics of a redirecting factory |
| 507 /// constructor invocation. | 521 /// constructor invocation. |
| 508 class RedirectingFactoryConstructorAccessSemantics | 522 class RedirectingFactoryConstructorAccessSemantics |
| 509 extends ConstructorAccessSemantics { | 523 extends ConstructorAccessSemantics { |
| 510 final ConstructorAccessSemantics effectiveTargetSemantics; | 524 final ConstructorAccessSemantics effectiveTargetSemantics; |
| 511 | 525 |
| 512 RedirectingFactoryConstructorAccessSemantics( | 526 RedirectingFactoryConstructorAccessSemantics( |
| 513 ConstructorAccessKind kind, | 527 ConstructorAccessKind kind, |
| 514 Element element, | 528 Element element, |
| 515 DartType type, | 529 DartType type, |
| 516 this.effectiveTargetSemantics) | 530 this.effectiveTargetSemantics) |
| 517 : super(kind, element, type); | 531 : super(kind, element, type); |
| 518 } | 532 } |
| 519 | 533 |
| 520 | 534 |
| OLD | NEW |