-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-Wunused:import
gets confused on import both locally and globally in file
#17667
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
Comments
What happens if |
It's just a bug in the warning. Reproducing all the import behaviors is tricky. |
- Import in the same scope, but after the usage are reported. - Add test suit i17667 - Fix test i15503a
Seems like it is only related to the order of the import, which is not accounted in the linting algorithm. Compiles :import scala.util.Try // unused
def foo =
val trying = Try(1)
import scala.util.Try Does NOT compile://import scala.util.Try // unused
def foo =
val trying = Try(1) // Not found: Try
import scala.util.Try |
I think this one should be solvable by being more precise which imports are in scope. Imports following a definition are never in scope for that definition. |
Ran into this when migrating workplace code to 3.3.0. Tried to minimize the code as much as possible, might be more available. When importing something from an object in the local scope and in global, unused:import gets confused about which one is actually needed.
Minimized code
Output
If I follow the "instructions" and remove the import on line 7..
gives
Though removing the other one
Removes the warning correctly
Expectation
The warning refers to the import that actually can be safely removed on line 10, not 7
The text was updated successfully, but these errors were encountered: