You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In selector check, prefix of reference must match import qualifier (#20894)
This PR changes the `CheckUnused` phase to rely on the `MiniPhase` API
(instead of custom traversal). That improves fidelity to `Context`
(instead of approximate scoping).
The phase should work seamlessly with subsequent linting phases
(currently, `CheckShadowed`).
It is a goal of the PR to eliminate false reports. It is also a goal not
to regress previous work on efficiency.
A remaining limitation of the current approach is that contexts don't
provide a nesting level. Practically, this means that for a wildcard
import nested below a higher precedence named import, the wildcard is
deemed "unused". (A more general tool for "managing" or "formatting"
imports could do more to pick a preferred scope.)
This PR adds `-Wunused:patvars`, as forward-ported from Scala 2: it
relies on attachments for some details about desugaring, but otherwise
uses positions (where only the original patvar has a non-synthetic
position).
As in Scala 2, it does not warn about patvars with the "canonical" name
of a case class element (this is complicated by type tests and the
quotes API); other exclusions are to be ported, such as "name derived
from the match selector".
Support is added for `-Wconf:origin=full.path.selector`, as in Scala 2.
That allows, for example:
```
-Wconf:origin=scala.util.chaining.given:s
```
to exclude certain blessed imports from warnings, or to work around
false positives (should they arise).
Support is added to `-rewrite` unused imports. There are no options to
"format"; instead, textual deletions preserve existing formatting,
except that blank lines are removed and braces removed when there is
only one selector.
Notable fixes are to support `compiletime` and `inline`; there are more
fixes to pursue in this area.
Fixes#19657Fixes#20520Fixes#19998Fixes#18313Fixes#17371Fixes#18708Fixes#21917Fixes#21420Fixes#20951Fixes#19252Fixes#18289Fixes#17667Fixes#17252Fixes#21807Fixes#17753Fixes#17318Fixes#18564Fixes#22376Fixes#21525
0 commit comments