Closed
Description
Java:
package j;
public class J {
protected boolean i() { return false; }
}
Scala:
package s
trait T { self: j.J =>
override def i(): Boolean = self.i() || true;
}
class C extends j.J with T
object Test {
def main(args: Array[String]): Unit = {
println(new C().i())
}
}
This crashes with IllegalAccessError: class s.T tried to access protected method j.J.i
.
Before scala/scala#8835, the compiler actually emitted a protected accessor in this example, so self.i
was actually acting like a super call.
If the two classes are in the same package, the method J.i
is accessible. In this case the runtime behavior is actually an infinite recursion, as it should be.