scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

"One of these files should be removed from the classpath" should be removed #21973

Open eed3si9n opened 3 days ago

eed3si9n commented 3 days ago

Steps

See https://github.com/scala/scala3/issues/17394, which was reported in May 2023 See also https://github.com/sbt/sbt/issues/7726

Problem

Under -Wunused:imports Scala 3 reports false warnings:

[warn] Unable to find a link for Id(Project) in extraProjects: dotty.tools.dotc.core.TypeError$$anon$1:
Toplevel definition overrideConfigs is defined in
[warn]   /home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/main_3/2.0.0-M2/main_3-2.0.0-M2.jar(sbt/BuildCommon.class)
[warn] and also in
[warn]   /home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/main_3/2.0.0-M2/main_3-2.0.0-M2.jar(sbt/ProjectExtra.class)
[warn] One of these files should be removed from the classpath.

Expectation

I have not looked into the details, but it seems like there's a feature interference between the -Wunused:imports linter and "One of these files should be removed from the classpath" error in dropStale (https://github.com/scala/scala3/blob/cc4a32451cec3b45d5c5c06a126fa37c8381ae72/compiler/src/dotty/tools/dotc/core/SymDenotations.scala#L2546-L2557). Given that we want to take the linters seriously, for example by paying attention, or turning them into -Werror, I suggest one of the two features to be removed in the short-term, assuming removal of a linter is relatively easy thing to do.

If someone has the bandwidth to fix the interference, then the linter can always come back.