Commit 237bb3b
[analyzer] Represent
This change introduces the class `FutureOrTypeImpl` to represent the
special types of the form `FutureOr<...>`, which were previously
represented as ordinary instances of `InterfaceType`.
This class mirrors the CFE's `FutureOrType` class. Adding it will
facilitate further code sharing between the analyzer and the CFE,
because it will allow code that's shared between the analyzer and CFE
to use `is` tests to recognize `FutureOr` types.
In a follow-up CL I intend to add a base class that is common to
analyzer and CFE `FutureOrType` representations.
Note that in https://dart-review.googlesource.com/c/sdk/+/396320, when
I introduced the `NullTypeImpl` class, I took pains to find all the
places in the analyzer that might call the `InterfaceTypeImpl`
constructor, and updated them so that if the type they are creating is
the `Null` type, they call the `NullTypeImpl` constructor
instead. That was tractable for the type `Null`, since there's
basically just a single `Null` type corresponding to a single
declaration in `dart:core`. At first I tried doing a similar thing for
`FutureOr`, but it proved to be a big pain, because `FutureOr` types
get created all over the place. It was difficult to be confident that
I'd updated all the necessary call sites. So instead I've put the
necessary logic in the `InterfaceTypeImpl` constructor itself (by
changing it into a factory constructor). This is a much lower risk
approach and I'm much happier with it. In a follow-up CL I'll change
the logic for `NullTypeImpl` to follow the same factory approach.
Change-Id: I54c6998f991456199076faeac995e433cc88845d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396523
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Paul Berry <[email protected]>FutureOr<...> as FutureOrTypeImpl.1 parent b3ee890 commit 237bb3b
File tree
2 files changed
+72
-7
lines changed- pkg/analyzer
- lib/src/dart/element
- test/generated
2 files changed
+72
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
460 | 488 | | |
461 | 489 | | |
462 | 490 | | |
| |||
493 | 521 | | |
494 | 522 | | |
495 | 523 | | |
496 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
497 | 547 | | |
498 | 548 | | |
499 | 549 | | |
500 | | - | |
| 550 | + | |
501 | 551 | | |
502 | 552 | | |
503 | 553 | | |
| |||
519 | 569 | | |
520 | 570 | | |
521 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
522 | 582 | | |
523 | 583 | | |
524 | 584 | | |
| |||
596 | 656 | | |
597 | 657 | | |
598 | 658 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | 659 | | |
605 | 660 | | |
606 | 661 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3082 | 3082 | | |
3083 | 3083 | | |
3084 | 3084 | | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
3085 | 3095 | | |
3086 | 3096 | | |
3087 | 3097 | | |
| |||
0 commit comments