Skip to content

Commit 86de7ec

Browse files
committed
Drop requirement that traits cannot access protected members of superclasses
Superaccessors handles this already correctly by generating a super accessor in this case.
1 parent b770c91 commit 86de7ec

File tree

3 files changed

+1
-43
lines changed

3 files changed

+1
-43
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,6 @@ object SymDenotations {
711711
i"""
712712
| Access to protected $this not permitted because enclosing ${ctx.owner.enclosingClass.showLocated}
713713
| is not a subclass of ${owner.showLocated} where target is defined""")
714-
else if (cls.is(Trait) && !this.owner.is(Trait))
715-
fail(
716-
i"""
717-
| Access to protected $this not permitted from $cls,
718-
| since traits cannot access protected members of superclasses""")
719714
else if (
720715
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
721716
|| pre.derivesFrom(cls)

tests/neg/protectedacc.scala

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/run/protectedacc.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ package p {
143143

144144
trait InnerInner {
145145
val g = getB
146-
//g.tie(self2.asInstanceOf[g.Node]) -- this would be a static error
146+
g.tie(self2.asInstanceOf[g.Node])
147147
}
148148
}
149149
}

0 commit comments

Comments
 (0)