Skip to content

False positive unused warning with -Wunused:params and extension #17101

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 Mar 14, 2023 · 2 comments · Fixed by #17178
Closed

False positive unused warning with -Wunused:params and extension #17101

mrdziuban opened this issue Mar 14, 2023 · 2 comments · Fixed by #17178
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Milestone

Comments

@mrdziuban
Copy link

Compiler version

3.3.0-RC3

Minimized code

https://scastie.scala-lang.org/mrdziuban/nBgViUmQQkiecLQSHAe71w/12

type Test[A] = A

extension [A](x: Test[A]) {
  def value: A = x
  def causesIssue: Unit = println("oh no")
}

Output

extension [A](x: Test[A]) {
           // ^
           // unused explicit parameter

Expectation

Since x is used in def value the parameter should not be reported as unused. This only happens when def causesIssue is present, so I'm guessing that this is related to how extension methods are desugared and the unused warning is because that particular method doesn't use x.

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 14, 2023
@nicolasstucki nicolasstucki 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 Mar 15, 2023
@SethTisue SethTisue changed the title False positive with -Wunused:params and extension False positive unused warning with -Wunused:params and extension Mar 27, 2023
@SethTisue
Copy link
Member

reported again today on Discord

@szymon-rd
Copy link
Contributor

For now, I made a PR that skips the extension methods altogether: #17178

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.

5 participants