Skip to content
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

-Wunused gives false positives on unused explicit parameters of (non-explicitly declared) overridden methods #16865

Closed
markehammons opened this issue Feb 9, 2023 · 2 comments · Fixed by #16965
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Milestone

Comments

@markehammons
Copy link

Compiler version

3.3.0-RC2

Minimized code

trait Base:
  def fn(a: Int, b: Int): Int 

object Ex extends Base:
  //false positive unused parameter
  def fn(a: Int, b: Int): Int = b + 3

object Ex2 extends Base:
  override def fn(a: Int, b: Int): Int = b + 3

Output

The compiler reports that fn in Ex has an unused explicit parameter a. This is the truth, but fn is an undeclared override of fn from Base.

Expectation

Either that the compiler doesn't warn, or complains that the user hasn't declared the override explicitly.

@markehammons markehammons added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 9, 2023
@jchyb jchyb added area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 9, 2023
@odersky
Copy link
Contributor

odersky commented Feb 11, 2023

@jchyb Maybe create a separate label for warn unused? There seem to be quite a lot of bug reports about that one specifically. That would make it easier to direct someone who can fix it to the issues.

@jchyb jchyb added area:linting Linting warnings enabled with -W or -Xlint and removed area:reporting Error reporting including formatting, implicit suggestions, etc labels Feb 12, 2023
@jchyb
Copy link
Contributor

jchyb commented Feb 13, 2023

Done, I went ahead and swapped area:reporting to area:warn-unused where applicable

szymon-rd added a commit that referenced this issue Feb 19, 2023
@szymon-rd, fixes #16865

- CheckUnused detects override from base type in addition of `override`
flag
- Update test suit
@Kordyjan Kordyjan modified the milestones: 3.3.1, 3.3.0 Aug 1, 2023
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.

4 participants