Skip to content

Commit 4eaf370

Browse files
authored
Merge pull request #3318 from dotty-staging/fix-#3302
Fix #3302: Handle case of private top-level objects
2 parents 1fe6567 + 46d0445 commit 4eaf370

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
7575
private def ensurePrivateAccessible(d: SymDenotation)(implicit ctx: Context) =
7676
if (isVCPrivateParamAccessor(d))
7777
d.ensureNotPrivate.installAfter(thisTransform)
78-
else if (d.is(PrivateTerm) && d.owner != ctx.owner.enclosingClass) {
78+
else if (d.is(PrivateTerm) && !d.owner.is(Package) && d.owner != ctx.owner.enclosingClass) {
7979
// Paths `p1` and `p2` are similar if they have a common suffix that follows
8080
// possibly different directory paths. That is, their common suffix extends
8181
// in both cases either to the start of the path or to a file separator character.

tests/pos/i3302/A.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package test
2+
//case class A(x: Int)
3+
private object A { def apply(x: Int) = () }

tests/pos/i3302/B.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package test
2+
object B {
3+
A(0)
4+
}

0 commit comments

Comments
 (0)