Skip to content

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

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

Open
eed3si9n opened this issue Nov 19, 2024 · 0 comments
Open
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug

Comments

@eed3si9n
Copy link
Member

Steps

See #17394, which was reported in May 2023
See also sbt/sbt#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 (

// pick the variant(s) from the youngest class file
val lastModDate = assocFiles.map(_.lastModified).max
val youngest = assocFiles.filter(_.lastModified == lastModDate)
val chosen = youngest.head
def ambiguousFilesMsg(f: AbstractFile) =
i"""Toplevel definition $name is defined in
| $chosen
|and also in
| $f"""
if youngest.size > 1 then
throw TypeError(em"""${ambiguousFilesMsg(youngest.tail.head)}
|One of these files should be removed from the classpath.""")
). 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.

@eed3si9n eed3si9n added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 19, 2024
@Gedochao Gedochao added area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants