Skip to content

@unused ignored when compiler option -Wunused:explicits/-Wunused:params is set #23122

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
aartigao opened this issue May 8, 2025 · 1 comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug stat:duplicate

Comments

@aartigao
Copy link

aartigao commented May 8, 2025

Compiler version

3.7.0

Minimized code

https://scastie.scala-lang.org/AcRqBnMOQvGVKyMGrNS7FQ

import scala.annotation.unused

@main def hello(): Unit =
  println(A(""))

class A(@unused param: AnyRef)

Output

-- [E198] Unused Symbol Warning
  |class A(@unused param: AnyRef)
  |                ^^^^^
  |                unused explicit parameter

Expectation

No warn emitted as the annotation should be taken into account.

@aartigao aartigao added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 8, 2025
@aartigao aartigao changed the title @unused ignored when compiler option -Wunused:explicits is set @unused ignored when compiler option -Wunused:explicits/-Wunused:params is set May 8, 2025
@som-snytt
Copy link
Contributor

som-snytt commented May 8, 2025

This is fixed in 3.7.1-RC1 but could use a test. I don't know at a glance what fixed it.

Edit: thanks to milestoning, I'm reminded that #23037

This commit just ensures unused annotation is retained for parameters. The previous tweak excluded constructor params (probably out of fear).

@som-snytt som-snytt self-assigned this May 8, 2025
@som-snytt som-snytt 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 May 8, 2025
@som-snytt som-snytt removed their assignment May 8, 2025
Gedochao pushed a commit that referenced this issue May 15, 2025
tgodzik pushed a commit to scala/scala3-lts that referenced this issue May 19, 2025
tgodzik added a commit to scala/scala3-lts that referenced this issue May 19, 2025
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 stat:duplicate
Projects
None yet
Development

No branches or pull requests

2 participants