Skip to content

Unused implicit conversion imports are not detected under certain circumstances #22976

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
jdrphillips opened this issue Apr 11, 2025 · 2 comments
Labels
area:implicits related to implicits area:linting Linting warnings enabled with -W or -Xlint itype:bug stat:fixed in next The issue was fixed in Next and only still applies to LTS.

Comments

@jdrphillips
Copy link

jdrphillips commented Apr 11, 2025

Compiler version

3.6.4

Minimized code

package testing

object Syntax {
  implicit def conversion(a: DummyClass): DummyClass = new DummyClass
}

class DummyClass

import Syntax.*

case class CaseClass(field: Boolean)

Note: I could not reproduce this in the REPL

Output

Expectation

The above code should return the following warning:

[warn] -- [E198] Test2.scala:9:14 
[warn] 9 |import Syntax.*
[warn]   |              ^
[warn]   |              unused import
[warn] one warning found

As far as I can tell, this warning behaves correctly for:

  • trait
  • class
  • abstract class
  • object
  • def

The warning behaves incorrectly for:

  • case class
  • case object (even trivial ones)

Note also this occurs even if the implicit conversion is completely irrelevant to any types involved, as in the above example

@jdrphillips jdrphillips added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 11, 2025
@som-snytt
Copy link
Contributor

3.7 warns.

-- [E198] Unused Symbol Warning: /home/amarki/snips/i22976.scala:6:26 ----------
6 |  implicit def conversion(a: DummyClass): DummyClass = new DummyClass
  |                          ^
  |                          unused explicit parameter
-- [E198] Unused Symbol Warning: /home/amarki/snips/i22976.scala:12:14 ---------
12 |import Syntax.conversion
   |              ^^^^^^^^^^
   |              unused import
there was 1 feature warning; re-run with -feature for details
3 warnings found

@Gedochao Gedochao added area:implicits related to implicits area:linting Linting warnings enabled with -W or -Xlint stat:fixed in next The issue was fixed in Next and only still applies to LTS. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 14, 2025
@Gedochao
Copy link
Contributor

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 stat:fixed in next The issue was fixed in Next and only still applies to LTS.
Projects
None yet
Development

No branches or pull requests

3 participants