In order to encapsulate anything to do with reflection, we must
overcome an issue with the boxing of primitives. If we declare a
method which takes arguments of type Any
, by the time the
method parameters can be examined, the primitives have already been boxed.
The reflective call will then fail because classOf[java.lang.Integer]
is not the same thing as classOf[scala.Int].
Any useful workaround will require examining the arguments before
the method is called. The approach here is to define two implicits,
one for AnyRef
's and one for AnyVal
's, and
box them in a container which preserves their original class identity.