Commit 731c55a
committed
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.1 parent 5e8272b commit 731c55a
File tree
5 files changed
+24
-29
lines changed- compiler/src/dotty/tools/dotc
- core
- typer
- tests
- neg
- run
5 files changed
+24
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
749 | | - | |
750 | | - | |
751 | | - | |
| 749 | + | |
752 | 750 | | |
753 | 751 | | |
754 | 752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 209 | + | |
217 | 210 | | |
218 | | - | |
| 211 | + | |
219 | 212 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 213 | + | |
224 | 214 | | |
225 | 215 | | |
226 | 216 | | |
227 | | - | |
| 217 | + | |
228 | 218 | | |
229 | 219 | | |
230 | 220 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments