-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.to(Col)
vs "unused import" warning
#240
Comments
@som-snytt there's a recent ticket on this elsewhere, isn't there? |
I'll check it out. Unused imports usually just works. |
OK, I see what you mean. They recommend that you use the "empty" import in 2.13, but of course it is actually unused. What a conundrum. Worst case, the warning could special-case the compatibility package under 2.13. Alternatively, don't warn if an import clause imports nothing. (That is less appealing.) |
I don't know if this is too quick and dirty, but scala/scala#8308 |
alternate alternative idea: separate warning flag |
Unfortunately, the import is not empty. Either the source preprocessor or the reporter postprocessor is required. Alternatively, a scalafix that is run as a source generator. |
is this |
I don't think
Running Sadly Update: I don't think we can use
package scala.collection {
package object compat
}
package here.is.a.test {
import scala.collection.compat._
} If we compile this with scalacOptions
You can see the site value is |
FSR no one mentioned I guess the reason is that the option is not available for 2.12. How very unfortunate! If the import were needed only on 2.13, then it would work as expected. At least I had an opportunity to re-read https://www.scala-sbt.org/1.x/docs/Cross-Build.html yet again but I forgot to notify Guinness book of world records before I attempted it. Maybe I can still get a mention in Ripley's Believe it or not. |
I spent some time with
with source file
There is a trade-off between specificity of import and complexity of the Issue for origin: |
One way to ensure your package is used on import:
|
The linked ticket was fixed. I am empowered to close this ticket, so I will do so in that context. |
to save others some digging: in Scala 2, scala/scala#9939 added support for whether Scala 3 also currently offers it, I don't know |
origin is scala/scala3#21404 and I'll check that imports uses it at scala/scala3#20894 |
I'm not sure how fixable this is, but using
.to(Coll)
on 2.13 causes "unused import" warnings, which is a pain when you havefatal-warnings
enabled.example: https://scastie.scala-lang.org/mc1Z3irYQ72gmPNgI96c6g
As a workaround right now I'm disabling the 2.13 version of the flag:
scalacOptions -= "-Wunused:imports"
The text was updated successfully, but these errors were encountered: