Commit 4c3e916
Allow (e as dynamic).foo() in avoid_dynamic_calls
The `(e as dynamic)` pattern is the intended workaround for intentional
dynamic calls. The lint currently allows this for property reads like
`(e as dynamic).foo` but disallows this for method invocations like `(e
as dynamic).foo()` because the latter falls into a case checking if the
`node.function` is the dynamic expression (to handle cases like
`(e as dynamic).call()`) but there it is no longer checking the right
expression for whether it is a cast.
Pull out an `_isExplicitCast` method to check for casts wrapped in
parenthesis. Use the explicit cast as a signal to bail earlier when
checking method invocations.
Change-Id: I77b1c28b38474cea018b61a3d0ebe38ead82378d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390640
Commit-Queue: Nate Bosch <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
Auto-Submit: Nate Bosch <[email protected]>1 parent b39bd0b commit 4c3e916
File tree
3 files changed
+24
-2
lines changed- pkg/linter
- lib/src/rules
- test/rules
3 files changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
198 | 210 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
542 | 550 | | |
543 | 551 | | |
544 | 552 | | |
| |||
0 commit comments