Skip to content

False positive unused warnings in 3.7 nightly on implicits in method overrides #22895

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

Closed
mrdziuban opened this issue Apr 1, 2025 · 3 comments · Fixed by #22901
Closed

False positive unused warnings in 3.7 nightly on implicits in method overrides #22895

mrdziuban opened this issue Apr 1, 2025 · 3 comments · Fixed by #22901
Assignees
Labels
area:implicits related to implicits area:linting Linting warnings enabled with -W or -Xlint itype:bug regression This worked in a previous version but doesn't anymore

Comments

@mrdziuban
Copy link

Compiler version

3.7.1-RC1-bin-20250328-d519790-NIGHTLY

Minimized code

trait Test[F[_], Ev] {
  def apply[A, B](fa: F[A])(f: A => B)(using ev: Ev): F[B]
}

given testId: Test[[a] =>> a, Unit] =
  new Test[[a] =>> a, Unit] {
    def apply[A, B](fa: A)(f: A => B)(using ev: Unit): B = f(fa)
  }

Output

[warn] -- [E198] Unused Symbol Warning: /Users/matt/scala3.7-nightly-unused/src/main/scala/example/Test.scala:7:44
[warn] 7 |    def apply[A, B](fa: A)(f: A => B)(using ev: Unit): B = f(fa)
[warn]   |                                            ^^
[warn]   |                                            unused implicit parameter

Expectation

The parameter should not be reported unused since it's required to satisfy the apply method override.

This is similar to #22742 which @som-snytt fixed in #22757 by suppressing unused warnings for explicit params in overrides -- could the same be done for implicits?

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 1, 2025
@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 Apr 1, 2025
@Gedochao
Copy link
Contributor

Gedochao commented Apr 1, 2025

Last good release: 3.7.0-RC1-bin-20250127-89c20f8-NIGHTLY
First bad release: 3.7.0-RC1-bin-20250128-9cb97ec-NIGHTLY

The first bad commit is one of:

(my money's on c65d45d)

This is technically a minor regression, but I have mixed feelings if we should treat it as such.
Still, adding the label.

@som-snytt, will you find the time to work on this?

@Gedochao Gedochao added regression This worked in a previous version but doesn't anymore area:implicits related to implicits labels Apr 1, 2025
@som-snytt som-snytt self-assigned this Apr 1, 2025
@som-snytt
Copy link
Contributor

Sorry I missed that on the previous ticket. Scala 2 has the expected behavior.

Not sure why sbt did this in the middle of session:

[success] Total time: 15 s, completed Apr 1, 2025, 8:37:04 AM
sbt:scala3> testCompilation 15503
[info] compiling 4 Java sources to /home/amarki/projects/dotty/sbt-bridge/src/target/classes ...
[info] Test run dotty.tools.dotc.CompilationTests started

@som-snytt
Copy link
Contributor

Also thanks @mrdziuban for the nifty test cases, it really spruces up the test suite.

@sjrd sjrd closed this as completed in c044420 Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits area:linting Linting warnings enabled with -W or -Xlint itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants