package p {
class C {
protected def f() = ()
}
class X {
this: C =>
def g() = f()
}
}
package p.s {
import p._
class Y {
this: C =>
def g() = f()
}
}
package q {
import p._
class Z {
this: C =>
def g() = f() // illegal access to protected method f in class C from class Z
}
}
Problem
Access to protected f requires that the enclosing class X be a subclass of C, not merely that this is.
Dotty currently allows access within p, per the linked ticket, but disallows in q.
Reproduction steps
Scala version: 2.13.11
Problem
Access to protected
f
requires that the enclosing classX
be a subclass ofC
, not merely thatthis
is.Dotty currently allows access within
p
, per the linked ticket, but disallows inq
.Scala 2 accepts the example.
Noticed at https://github.com/lampepfl/dotty/issues/18245