Open WojciechMazur opened 3 weeks ago
I have an improvement PR and also a branch for a rewrite of the unused check, where I noticed that the scoping in "super position" is not correct:
object Constants:
final val i = 42
class `scope of super`:
import Constants.i // bad warn
class C(x: Int):
def y = x
class D extends C(i):
import Constants.* // does not resolve i in C(i)
def m = i
confirming with current scalacQ
➜ snips ~/projects/dotty/bin/scalacQ -d /tmp/sandbox -Wunused:imports import-scope.scala
-- [E198] Unused Symbol Warning: import-scope.scala:5:19 -----------------------
5 | import Constants.i // bad warn
| ^
| unused import
1 warning found
I don't think the crude scoping in the check could ever quite work; if it is a regression here in the May improvements, I assume that is because more is correctly detected.
By "crude", I mean that typer contexts are approximated.
I noticed it (on my rewrite branch, which doesn't go far) by turning on the lint in the dotty build, i.e., dogfooding.
Compiler version
3.5.0 and later Bisect points to 975df4a136910fe0451514ef0dc34aa29a60aef7
Minimized code
Output
Expectation
Should not report warnings if wildcard import is placed after usages of explicit import statement.