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

Open
scabug opened this Issue Jul 30, 2013 · 7 comments

Comments

Projects
None yet
6 participants
@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Feb 17, 2014

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

@scabug

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Oct 28, 2016

@lrytz

This comment has been minimized.

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

This comment has been minimized.

Copy link

som-snytt commented Mar 1, 2018

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.

@SethTisue SethTisue modified the milestones: 2.12.6, Backlog Mar 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.