Aladdin - Scala Bugtracking
[#857] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-12-01 13:25:16.0
subject cannot access protected members through non-this in indirect subclass
code
// From the Scala list email, a simplified version
package core;
class Bar extends Fish {
  (new Fish).runSafe 
  this.runSafe
}
class Fish extends Mapper {
  (new Fish).runSafe 
}
class Mapper {
  protected def runSafe : Unit = null;
}
what happened
Severity and De5cr1p7-haX0Rion	Path	Resource	Location	Creation Time	Id
method runSafe cannot be accessed in core.Fish	test40/src/core	Test.scala	line 3	1164976027126	225777
what expected No type error.
[back to overview]
Changes of this bug report
Sean  edited on  2006-12-01 13:28:24.0
Completely mis-classified this bug, has nothing to do with companion modules.
Sean  edited on  2006-12-01 13:29:06.0
Sean  edited on  2006-12-01 13:29:38.0
Sean  edited on  2006-12-01 13:41:49.0
Martin  edited on  2006-12-01 17:09:23.0
Actually it has to do with companion modules. The example code given is is in error. To see that compare with the Java translation:
// two files:
// bug857a.java
package bar;
import fish.Fish;
class Bar extends Fish {
    {
        new Fish().test();
        new Fish().runSafe();
    }
}    
// Fish.java
package fish;
public class Fish extends Mapper {

    void moo() { new Fish().runSafe(); }
    protected void test() {}
}
abstract class Mapper {
    protected void runSafe() {}
}

/home/odersky/scala/test/files/new> jc -source 1.5 bug857a.java Fish.java
bug857a.java:5: test() has protected access in fish.Fish
        new Fish().test();
        ^
bug857a.java:6: runSafe() has protected access in fish.Mapper
        new Fish().runSafe();
        ^
2 errors
However, the original contribution did show a bug, which I fixed.