Skip to content

Commit 15b4c2a

Browse files
committed
Fix condition in expandPrivate
Previous condition did not take into account private static members. Their "enclosing class" is the enclosing package, but we really want to count them as static members of their lexical enclosing class here.
1 parent 5e01703 commit 15b4c2a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

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

tests/run/i3006b.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Foo$$_$bar$1
2-
Foo$$_$bar$2
3-
Bar$$_$bar$1
1+
bar$1
2+
bar$2
3+
bar$1

0 commit comments

Comments
 (0)