-
Notifications
You must be signed in to change notification settings - Fork 21
package-private method should not be overridable outside of the package #11339
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
Comments
Access and matching members for overriding are different. You can widen the access when overriding, just like in Java, pardon the expression. |
"widen the access when overriding" is fine. The problem is that I can override something I shouldn't have access to in the first place. |
Yup, that's the intuition expressed somewhere in the linked tickets. The spec says http://www.scala-lang.org/files/archive/spec/2.12/05-classes-and-objects.html#overriding that the member you're overriding must have a narrower But if a member |
The last paragraph would apply to |
I think paulp complained about that and then changed it at some point. |
As usual, I'm years behind @paulp. |
@TomasMikula I can maybe save you a little bit of time here: qualified private/protected have no chance whatsoever of ever working correctly. |
@paulp has a way of cutting to the chase. Or to the quick. |
The spec language in 5.2.1 "private" was changed in 2015 to clarify:
issue 9321 at scala/scala@99fcdf7 There is also a mention in Scala 3 that they might just get rid of qualified private. Pun on "busted down to private". |
This compiles, even though
filterImpl
is declaredprivate[scala]
inTraversableLike
.Another problem is that I cannot have a (private) method of the same name and arguments as a package-private method without overriding the package-private method:
The text was updated successfully, but these errors were encountered: