You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert #3735: Allow accesses to private package members from nested
Test case is i3339. In
```
package outer {
private class A() {
override def toString = "A"
}
package inner {
object Test {
def main(args: Array[String]): Unit = {
println(new A()) // allow access?
}
}
}
}
```
should the access to private class `A` from a nested package be allowed?
The usual rules for Scala say yes, since the access is from a nested scope.
We changed this to in #3735 to "no", since we wanted to emulate Java's default
package-private visibility. But this is unsystematic for two reasons:
- it breaks the universal meaning of `private` in Scala
- it uses a different name (i.e. private) for what is not named
in Java at all, and is named `internal` in Kotlin.
- it does not generalize to members of classes which could
also profit from a Java-package-private visibility specifier.
I believe it is better to leave `private` as it is, and, if we want to
emulate `internal` (which might be a good idea), introduce a new modifier
for it.
0 commit comments