Aladdin - Scala Bugtracking
[#772] project: compiler priority: low category: bug
submitter assigned to status date submitted
Iulian _ _ 2006-10-10 17:53:39.0
subject implementations of trait inherited methods shouldn't be 'protected'
code
trait A {
  protected def foo = "abc";
}

class B extends Object with A {
  override protected def foo = "cde"
}
what happened
If one calls A.foo on some instance of B it will get an IllegalAccessError. The reason is that trait A is transf\
ormed into an interface A, which is implemented by class B. Method 'foo' in the interface is public, but its imp\
lementation is 'protected', and generates a runtime exception.

The reason this is not happening right now is that the backend ignores 'protected' modifiers.
what expected I see three options (listed in the order of my preference): - the mixin phase makes such methods public. - the backend continues to ignore protected modifiers. - the compiler rejects such code with an error.
[back to overview]
Changes of this bug report