Commit 7739459
[analyzer] Move switch expression resolution into ResolverVisitor.
The analyzer uses two different mechanisms to visit expressions during
resolution:
- `Expression.accept` (which defers to `ResolverVisitor.visit...`
methods using the standard visitor infrastructure), and
- The abstract method `ExpressionImpl.resolveExpression` (which is
implemented in every expression type).
The `Expression.accept` approach doesn't support contexts, so it is
only used when the context is the unknown type schema (`_`).
(The reason there are two approaches is largely a historical accident,
and I hope one day to unify them into a single approach. But that's
not the subject of this change.)
Prior to this change, the resolution logic for most expression types
was in the `visit...` method, and the corresponding
`resolveExpression` method did nothing but call `visit...`. But there
was one exception: for switch expressions, the resolution logic was in
`resolveExpression`, and the corresponding `visit...` method called
`analyzeExpression` (which then called `resolveExpression`).
This change moves the resolution logic for switch expressions into the
`visit...` method, and changes the corresponding `resolveExpression`
method to call `visit...`. This makes switch expression resolution
consistent with all other expression types, which should make the
resolution logic easier to reason about.
There should be no functional change.
Change-Id: I209cdb5cd721608f60e6668a4be76fd20a7452de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398585
Auto-Submit: Paul Berry <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>1 parent abb17bc commit 7739459
File tree
2 files changed
+10
-12
lines changed- pkg/analyzer/lib/src
- dart/ast
- generated
2 files changed
+10
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17111 | 17111 | | |
17112 | 17112 | | |
17113 | 17113 | | |
17114 | | - | |
17115 | | - | |
17116 | | - | |
17117 | | - | |
17118 | | - | |
17119 | | - | |
17120 | | - | |
17121 | | - | |
17122 | | - | |
17123 | | - | |
17124 | | - | |
| 17114 | + | |
17125 | 17115 | | |
17126 | 17116 | | |
17127 | 17117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3770 | 3770 | | |
3771 | 3771 | | |
3772 | 3772 | | |
3773 | | - | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
3774 | 3780 | | |
| 3781 | + | |
| 3782 | + | |
3775 | 3783 | | |
3776 | 3784 | | |
3777 | 3785 | | |
| |||
0 commit comments