You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to invoke a super method from java base class I got a very strange error:
Unexpected tree in genLoad: Worker.super/classscala.reflect.api.Trees$Superat: source-..\Worker.scala,line-9,offset=130whilecompiling: Worker.scala
current phase: icode
library version: version 2.10.0-20120406-151649-1a6408c429
compiler version: version 2.10.0-20120406-151649-1a6408c429
uncaught exception during compilation: scala.reflect.internal.FatalError
scala.reflect.internal.FatalUnexpected tree in genLoad: Worker.super/classscala.reflect.api.Trees$Superat: source-...\Worker.scala,line-9,offset=130
at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:40)
at scala.tools.nsc.Global.abort(Global.scala:191)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1105)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1150)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:721)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:901)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:115)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:71)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:77)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:140)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:90)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:81)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:67)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:63)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:421)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:387)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:381)
at scala.collection.Iterator$class.foreach(Iterator.scala:697)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1124)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:381)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:56)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1303)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1276)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1270)
at scala.tools.nsc.Global$Run.compile(Global.scala:1403)
at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
at scala.tools.nsc.Main$.doCompile(Main.scala:81)
at scala.tools.nsc.Driver.process(Driver.scala:52)
at scala.tools.nsc.Driver.main(Driver.scala:65)
at scala.tools.nsc.Main.main(Main.scala)
Finally I was able to reproduce this case. The problem arise when you override a method in base class hierarchy
where class which defines a given method has a package access modifier.
Here a example:
//base abstract public classpackagecom.test;
public abstractclassBase {
}
//class in the middle of the inheritance chain that has a package wide accesspackagecom.test;
classMiddleextendsBase {
public void doSomething() {
System.out.println("You just called a base class!");
}
}
//a public class that inherits from a previous classpackagecom.test;
public classTopextendsMiddle {
}
//a scala class that inherits from a public class but overrides a method defined in class with default accessimportcom.test.TopclassWorkerextendsTop {
overridedefdoSomething() {
super.doSomething()
}
}
Of course this case should be rare in practice but at least the compiler should not crash on this.
The text was updated successfully, but these errors were encountered:
Aliaksandr Zhuhrou (zhygr) said:
Also the related problem that you may actually override a inaccessible method and in you don't call super the compiler say you nothing.
But in the end you get an IllegalAccessException.
Example
import com.test.Top
class Worker extends Top {
override def doSomething() { System.out.println("Hm. It works.") }
}
In this case my intuition says that compiler should also give you a meanfull error.
When trying to invoke a super method from java base class I got a very strange error:
Finally I was able to reproduce this case. The problem arise when you override a method in base class hierarchy
where class which defines a given method has a package access modifier.
Here a example:
Of course this case should be rare in practice but at least the compiler should not crash on this.
The text was updated successfully, but these errors were encountered: