Commit 37ae078
Analyzer: Fix incorrect type in PropertyElementResolver._resolve.
The `unpromotedType` computed by `PropertyElementResolver._resolve`
(which eventually propagates to both `FlowAnalysis.propertyGet` and to
`PropertyElementResolverResult.getType`) is intended to represent the
static type of the "property get" expression in the absence of
promotion. If the property get targets a `PropertyAccessorElement` (a
getter), this is the getter's return type. But if it targets a
`MethodElement`, this is the function type of the method (because the
"property get" is doing a tear-off of the method).
Previously, `PropertyElementResolver._resolve` was always using the
return type, meaning that if the property get was targeting a
`MethodElement`, it was computing the wrong type. Fortunately, this
didn't lead to any bugs, because (a) the type passed to
`FlowAnalysis.propertyGet` is only used for determining whether a
field access should be promoted, and method tear-offs aren't
promotable, and (b) the analyzer only uses the type stored in
`PropertyElementResolverResult.getType` when the element being
targeted is a `PropertyAccessorElement`.
I'm in the middle of a larger arc of work trying to introduce a new,
simpler mechanism for flow analysis to be told about the static types
of property gets, and part of that arc of work will involve
introducing a temporary check to verify that the old and new
mechanisms see the same static types. Fixing this incorrect type will
allow the temporary check to pass.
Change-Id: Ib13b12d1176a781dc56c3e79c150df481b48a0d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390585
Commit-Queue: Paul Berry <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>1 parent 7e7da42 commit 37ae078
File tree
1 file changed
+5
-2
lines changed- pkg/analyzer/lib/src/dart/resolver
1 file changed
+5
-2
lines changedLines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
491 | | - | |
492 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
493 | 496 | | |
494 | 497 | | |
495 | 498 | | |
| |||
0 commit comments