Aladdin - Scala Bugtracking
[#665] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Iulian fixed 2006-07-18 07:07:41.0
subject another crash
code
package test;
abstract class Test {
  protected def foo = {}
}
trait Test2 extends Test {
  def bar = foo;
}
what happened
sean-mcdirmids-computer:~/workspace/test/src mcdirmid$ ~/workspace/scala/build/quick/bin/scalac -d ../bin -sourc\
epath . test/Test.scala                     
Exception in thread "main" scala.tools.nsc.symtab.Types$TypeError: method foo cannot be accessed in test.Test
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:201)
        at scala.tools.nsc.typechecker.Typers$Typer.reportTypeError(Typers.scala:148)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1767)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1785)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$21.apply(Erasure.scala:617)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$21.apply(Erasure.scala:614)
        at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:71)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:614)
        at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1059)
        at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:22)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:216)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:205)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:205)
        at scala.Iterator$class.foreach(Iterator.scala:304)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:205)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:467)
        at scala.tools.nsc.Global$Run.compile(Global.scala:531)
        at scala.tools.nsc.Main$.process(Main.scala:76)
        at scala.tools.nsc.Main$.main(Main.scala:98)
        at scala.tools.nsc.Main.main(Main.scala)
Note: changing Test from an abstract class to trait eliminates the crash.
what expected
[back to overview]
Changes of this bug report
Martin  edited on  2006-07-18 23:05:23.0
I could fix it for the given case, and in all cases where both superclass and inheriting trait are Scala classes. However, I noted that the `protected' gets eliminated in the javap output. Iulian, is the backend doing that, and under what circumstances? My problem is that if the `protected' is *not* eliminated then we still might have a problem with traits that inherit from Java classes.
Martin  edited on  2006-07-18 23:34:31.0
OK, I verified that it does work if Test is a Java class with a protected. So the bug is closed now. However, I still have two questions: 1. Why is the backend eliminating `protected' modifiers? 2. It seems the JVM is not enforcing the protected access rule that the access must happen from within a class that is a subclass of the protected function. Note that the access to `foo' happens in class Test2$class which is not a subclass of Test.
Martin  edited on  2006-07-24 16:38:08.0
Iulian indicated that the JRE does indeed throw a verify error. I leave the bug open as a reminder.
Martin  edited on  2006-08-22 16:31:32.0
Iulian  edited on  2007-03-01 10:46:37.0
Seems to have been fixed by some other bug fix.