Commit 451cc74
authored
Warn trivial recursion with module prefix (#23278)
Fixes #23277
First, loosen the test for whether to warn for `module.recur()`. The
`this` assignment has a RHS that is not pure (because of module init)
but `isStable` (and not significant with respect to the warning).
Second, avoid emitting such a `this` assignment if the prefix is the
enclosing module. The existing code checks for a prefix that is
`Enclosing.this`.
Other "aliasing" prefixes are not considered, such as a method with
result `this.type`, since they could execute arbitrary intended effects.1 parent 2d18655 commit 451cc74
File tree
2 files changed
+27
-1
lines changed- compiler/src/dotty/tools/dotc/transform
- tests/warn
2 files changed
+27
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments