Description
Compiler version
3.5.2
Minimized code
Scala 2 allows suppressing pesky "unused imports" by -Wconf:origin=p.m:s
.
That is handy not only to work around false positives but to permit certain imports to go unused rather than deleting and restoring them incidentally. For example, one may wish to import core.Contexts.*
everywhere, even if unused; or,
import scala.util.chaining.given
for its occasional utility.
➜ snips cat unused-import.scala
package example
import annotation.*
class C {
}
➜ snips scalac -d /tmp/sandbox -Xsource:3 -Werror -Wunused unused-import.scala
unused-import.scala:4: warning: Unused import
import annotation.*
^
error: No warnings can be incurred under -Werror.
1 warning
1 error
➜ snips scalac -d /tmp/sandbox -Xsource:3 -Werror -Wunused -Wconf:origin=scala.annotation._:s unused-import.scala
➜ snips
Output
The configuration is parsed but not matched.
Expectation
I see the guy promised to add it (see the ticket) but here's another ticket to remind him. Adding origin was this PR and the lint effort he mentions is this other PR. Apparently, he just forgot, because he just tried it to work around this issue and it doesn't work yet.
Maybe also add a cat=
category for linting, if it's not too much trouble. Or at least error IDs, etc, as has been requested elsewhere.