Skip to content

Fix #5827: Don't copy protected flag to apply method of case class #5830

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

Merged
merged 2 commits into from
Feb 2, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 1, 2019

No description provided.

@odersky odersky requested a review from nicolasstucki February 1, 2019 09:32
@odersky odersky added the fasttrack Simple fix. Reviewer should merge or apply additional changes directly. label Feb 1, 2019
@Jasper-M
Copy link
Contributor

Jasper-M commented Feb 1, 2019

On the one hand, with the current semantics of protected a protected method in an object is a bit silly as it is more or less the same as a private one. But on the other hand, it's a bit inconsistent to special case private. And why would anyone make a constructor protected if they still automatically get a public factory method?

Actually I would half expect the companion object of a class to have access to the protected members of the superclass of that class, and of the companion object of that superclass. But that's another can of worms...

@odersky
Copy link
Contributor Author

odersky commented Feb 1, 2019

@Jasper-M protected simply makes no sense in an object, so we have to drop it.

@nicolasstucki nicolasstucki merged commit 4418821 into scala:master Feb 2, 2019
@nicolasstucki nicolasstucki deleted the fix-#5827 branch February 2, 2019 06:31
Garmelon pushed a commit to Garmelon/keymaerax that referenced this pull request Jul 3, 2025
This feature switches on Scala 3 behavior regarding the visibility of
case class copy and apply methods.

In particular, when the case class constructor is private, the generated
copy and apply methods are private as well.

When the case class constructor is protected, the generated copy method
is protected as well, but the generated apply method in the companion
object is still public (see scala/scala3#5830).

See also scala/scala#7702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fasttrack Simple fix. Reviewer should merge or apply additional changes directly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants