Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix -Wunused:import registering constructor ("<init>") instead of its…
… owner (also fix false positive for enum) (#16661) This solves the issue #16650. The issue is that `member(sym.name)` failed to resolve when a type contains multiple identical name. Here the `dotty.tools.dotc.util` package contains multiple "<init>" (constructor), so `member` fail to resolve the name The solution is to register the owner of the contructor instead of the constructor itself. :warning: I couldn't create a test where this appends, I tested it by `publishLocal` and testing the code in a different project with this code from #16650 (also didn't check on the metals build): ```scala //> using lib "org.scala-lang::scala3-compiler:3.3.0-RC1-bin-20230109-f56089b-NIGHTLY" //> using scala "3.3.0-RC1-bin-20230109-f56089b-NIGHTLY" //> using option "-Wunused:all" import dotty.tools.dotc.util.LinearSet @main def run = val a = 123 println("Hello!") ``` ```bash sbt> run [info] compiling 1 Scala source to .../target/scala-3.3.0-RC1-bin-SNAPSHOT/classes ... [warn] -- Warning: ..../src/main/scala/Main.scala:5:29 [warn] 5 |import dotty.tools.dotc.util.LinearSet [warn] | ^^^^^^^^^ [warn] | unused import [warn] -- Warning:.../src/main/scala/Main.scala:10:6 [warn] 10 | val a = 123 [warn] | ^ [warn] | unused local definition [warn] two warnings found [info] running run Hello! ``` ### EDIT Also add a related fix for import generated by enum (false positive)
- Loading branch information