I just re-opened the bug again, because the current fix is not sufficient. Currently, AnyVal is declared to be sealed. One implication of this is that it's not possible to subclass AnyVal. But it's still possible to subclass existing value classes like Byte, Short, Int, etc. These classes should be either final or at least sealed. Otherwise it's quite easy to crash the compiler. Here is an example:
class T extends Unit;
This yields the following exception:
{
scala.Unit();
scala.runtime.RunTime.box()
}
Exception in thread "main" java.lang.AssertionError
at scalac.transformer.AddConstructors.transform(AddConstructors.java:211)
at scalac.ast.Transformer.transform(Transformer.java:276)
at scalac.ast.Transformer.apply(Transformer.java:67)
at scalac.transformer.AddConstructorsPhase.apply(AddConstructorsPhase.java:42)
at scalac.Global.compile(Global.java:266)
at scalac.Global.compile(Global.java:245)
at scalac.Main.main(Main.java:32)
|