Aladdin - Scala Bugtracking
[#780] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak Martin fixed 2006-10-18 12:14:51.0
subject [contrib #228] accessing protected val in required trait causes compiler crash
code
class B extends A { protected val x = false }
trait A requires B { x }
what happened
Compiler crashes:
exception when typing A$class.this.x
exception when typing A$class.this.x()
exception when typing abstract trait A$class requires B extends java.lang.Object with scala.ScalaObject$class wi\
th A {
  def /*A$class*/$init$(): scala.Unit = {
    ()
  };
  A$class.this.x()
}
exception when typing package  {
  class B extends java.lang.Object with A with scala.ScalaObject {
    def this(): B = {
      B.super.this();
      B.this./*A$class*/$init$();
      ()
    };
    private  val x: scala.Boolean = false;
    protected   def x(): scala.Boolean = B.this.x
  };
  abstract trait A requires B extends java.lang.Object with scala.ScalaObject;
  abstract trait A$class requires B extends java.lang.Object with scala.ScalaObject$class with A {
    def /*A$class*/$init$(): scala.Unit = {
      ()
    };
    A$class.this.x()
  }
}
Exception in thread "main" scala.tools.nsc.symtab.Types$TypeError: value x cannot be accessed in B
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:213)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:240)
        at scala.tools.nsc.typechecker.Infer$Inferencer.errorTree(Infer.scala:243)
        at scala.tools.nsc.typechecker.Infer$Inferencer.accessError$0(Infer.scala:279)
        at scala.tools.nsc.typechecker.Infer$Inferencer.checkAccessible(Infer.scala:297)
        at scala.tools.nsc.typechecker.Typers$Typer.typedSelect$0(Typers.scala:1414)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1822)
        at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:394)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1900)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1753)
        at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:394)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1900)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1928)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1092)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$47.apply(Typers.scala:1113)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$47.apply(Typers.scala:1113)
        at scala.List$.loop$0(List.scala:238)
        at scala.List$.mapConserve(List.scala:255)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1113)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:778)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:700)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1553)
        at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:394)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1900)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1928)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1092)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$47.apply(Typers.scala:1113)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$47.apply(Typers.scala:1113)
        at scala.List$.loop$0(List.scala:238)
        at scala.List$.mapConserve(List.scala:255)
        at scala.List$.loop$0(List.scala:242)
        at scala.List$.mapConserve(List.scala:255)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1113)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1549)
        at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:394)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1900)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1928)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$23.apply(Erasure.scala:682)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$23.apply(Erasure.scala:679)
        at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:71)
        at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:679)
        at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1090)
        at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:39)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:218)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:207)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:207)
        at scala.Iterator$class.foreach(Iterator.scala:316)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:220)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:207)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:469)
        at scala.tools.nsc.Global$Run.compile(Global.scala:535)
        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)
This happens with SVN repository revision 8898.
what expected Silent compilation as in SVN revision 8713.
[back to overview]
Changes of this bug report
Nikolay  edited on  2006-10-19 12:30:45.0
Transferred from the contributions and assigned to Iuli (I remember sth about protected accessors form his status report)
Iulian  edited on  2006-10-19 15:55:34.0
Protected accessors are not part of the release, this crash comes from something else. It seems like erasure is not introducing a required cast to 'B' before accessing 'x' (so the error message is right, in a way). I reassigned this to Martin, since the latest commits to Erasure.scala seem to be responsible for that (scala v. 2.1.8 accepts this program).
Martin  edited on  2006-10-20 18:44:35.0