Aladdin - Scala Bugtracking
[#683] project: specification priority: low category: missing feature
submitter assigned to status date submitted
Sean Martin won't fix 2006-07-31 14:40:56.0
subject setter access rights
code
package test;

abstract class Test {
  trait Foo {
    var x0 : Int = 0;
    protected def x = x0;
    def x_=(x1 : Int) = x0 = x1;
  }
  def foo : Foo;
  foo.x = 10;
  // OK: foo.x_=(10);
}
what happened
method x cannot be accessed in Test.this.Foo
what expected the x setter is public so should be accessible. Note that using the x_=(10) syntax avoids the type error, and making the x getter public also avoids the type error.
[back to overview]
Changes of this bug report
Martin  edited on  2006-08-20 17:03:41.0
The spec says that, to interprete foo.x = ..., we first interprete foo.x; if this is a getter, then we transform this to foo.x_=(...). This implies that if foo.x is not type correct, there's nothing we can do about it. So the compiler is in accordance with the spec, it seems to me. And I would be reluctant to generalize the spec any further at this point.
Sean  edited on  2006-08-21 10:32:29.0
Oh. I thought = ... was just syntactic sugar for _=(...). Guess it is much more complicated than that, sorry for the noise.