Hi everyone,
I was working on hiding the AnyRef specialization under a flag, as discussed in
SI-6103.
I stumbled on the fact that Definitions.AnyRefModule is not available in superaccessors and I don't know how to force it to become available sooner.
If I access Definitions.AnyRefModule in specialization, all is well, but if I access it in superaccessors I get:
uncaught exception during compilation: scala.reflect.internal.FatalError
error: scala.reflect.internal.FatalError: package scala does not have a member object AnyRef at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:979)
at scala.reflect.internal.Definitions$DefinitionsClass.getMemberModule(Definitions.scala:1022) at scala.reflect.internal.Definitions$DefinitionsClass.AnyRefModule$lzycompute(Definitions.scala:248)
at scala.reflect.internal.Definitions$DefinitionsClass.AnyRefModule(Definitions.scala:248) at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:239)
at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:43)The "AnyRef module" is actually defined in src/library/scala/package.scala as:
// A dummy used by the specialization annotation. val AnyRef = new Specializable {
override def toString = "object AnyRef" }
If I transform that to
object AnyRef extends Specializable all goes well, so I imagine there's some magic going on somewhere to transform the val into an object.
I traced the val change to
this commit, and it seems the motivation for having a val is that <cite>it's bad juju to place objects inside package objects</cite>. (I'm not kidding, search for juju in the diff)
My questions are:
1) Can we accept the bad juju and make AnyRef an object again?
2) If we need to keep the val, what is the val2object magic incantation so I trigger it earlier?
Any help is greatly appreciated!
Thanks,
Vlad