Hi Tony,
I am trying to do rewrites on an AST where some nodes are value classes and this fails in the `dup` method.
My current workaround is
override def dup[T <: Product](t : T, children : Array[AnyRef]) : T =
super.dup(t, children map unbox)
/** value classes must be unboxed before duplication */
def unbox(s: AnyRef): AnyRef = {
val klass = s.getClass
s match {
case p: Product if Modifier.isFinal(klass.getModifiers) && p.productArity == 1 =>
p.productElement(0).asInstanceOf[AnyRef]
case _ =>
s
}
}
I don't think this is great because it would fail on the other hand it will fail on rewriting a final case class with one argument.
Unfortunately we don't know if a "Class" is a AnyVal at this stage.
What do you think?
Eric.