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

Spurious "private default argument... is never used" warning with -Xlint #7707

Closed
scabug opened this issue Jul 30, 2013 · 8 comments · Fixed by scala/scala#8406
Closed

Spurious "private default argument... is never used" warning with -Xlint #7707

scabug opened this issue Jul 30, 2013 · 8 comments · Fixed by scala/scala#8406

Comments

@scabug
Copy link

scabug commented Jul 30, 2013

object O { O() }
case class O private (x: Int = 3)

gives (in 2.11.0-M4)

warning: private default argument in object O is never used
       case class O private (x: Int = 3)
                             ^

but it is; it's used from the companion object.

@scabug
Copy link
Author

scabug commented Jul 30, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7707?orig=1
Reporter: @SethTisue
Affected Versions: 2.11.0-M4

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@retronym said:
PR to remove unused warnings form Xlint: scala/scala#3544

@scabug
Copy link
Author

scabug commented Sep 13, 2016

@som-snytt said (edited on Sep 16, 2016 5:48:16 PM UTC):
Actually the default arg to the constructor is never used. If the constructor is private, then the apply is not rewritten to new, neither within the companion nor within the case class itself. What is used is the public default arg to apply.

It probably shouldn't warn about the synthetic member anyway. Edit: The warning intentionally warns about unused default getters. One can also ask whether the apply defaults should forward to the ctor defaults.

@scabug
Copy link
Author

scabug commented Sep 27, 2016

@som-snytt said:
This fix has the case apply transform also transform the default arg getter that is invoked.

scala/scala#5425

@scabug
Copy link
Author

scabug commented Oct 28, 2016

@adriaanm said:
See scala/scala#5402

@lrytz
Copy link
Member

lrytz commented Mar 1, 2018

This issue is still present in 2.12.4 (and 2.12.x shortly before 2.12.5).

@lrytz lrytz modified the milestones: 2.12.5, 2.12.6 Mar 1, 2018
@hrhino hrhino changed the title 2.11: spurious "private default argument... is never used" warning with -Xlint Spurious "private default argument... is never used" warning with -Xlint Mar 1, 2018
@som-snytt
Copy link

I don't remember why that commit didn't make it onto the slow train of warning fixes. I'll take a look during some relaxing weekend at the beach when I have nothing better to do.

@som-snytt
Copy link

This was not a relaxing weekend, but I had nothing better to do.

Note that there is no way to mark a default arg @unused.

@SethTisue SethTisue removed this from the Backlog milestone Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants