-
Notifications
You must be signed in to change notification settings - Fork 2
add support for -Wunused #287
Comments
this also blocks support for remove unused imports rewrites |
FYI, I just started working on scalafix-rule to detect unused parameter, imports, patvars, local defs, and private fields that works consistently between Scala2 and Scala3. https://github.com/tanishiking/scalafix-unused |
@som-snytt do you have a sense of how plausible it is to implement this outside of the compiler? does Scalafix have enough information to do this? |
As a use case, consider whether an import or definition was "used" during implicit search. In Scala 2, the restriction was that "only the compiler implementation knows." There is a cost for a third-party implementation for these checks. I think the compiler should expose API. I prefer the idea of the compiler exposes data, and third-party components provide the analysis. But at this point, there is no chance of supporting both 2 & 3 that way. |
In terms of implicit search, semanticdb has Synthetics section and it contains implicit parameters and implicit conversions. Therefore we should be able to handle those checks. However, yes there could be some limitations because semanticdb has definitely less information than compiler APIs. I'd like to see if scalafix/semanticdb really feasible to create a robust rule :) |
perhaps this should be in dotty-feature-requests there's an umbrella thread about linting in Scala 3 at https://contributors.scala-lang.org/t/replacement-for-xlint-in-scala3/5241 |
@bishabosha what is the current status of this feature request? It would be great to be able to e.g. use Scalafix's |
Current status: so far, no one has stepped up to implement this feature. |
Taking a look now. I'm willing to entertain any preconceived notions. I haven't looked at current Scalafix yet. Sample urgency:
We may not be 100% cat-compatible. |
Hi @som-snytt , just curious if you had any further finds. More generally, maybe someone could briefly describe the compiler phases that would be best to take a look at in implementing this feature and any other high-level suggestions. Thanks! |
unused imports is at scala/scala3#14524 |
I think we can close it indeed. There are some edges to clean up but we have issues tracking that. |
build.sbt with
Produces:
The text was updated successfully, but these errors were encountered: