scala.reflect.Invocation

trait PrimitivePreserver

[source: scala/reflect/Invocation.scala]

trait PrimitivePreserver[T]
extends AnyRef

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.

Direct Known Subclasses:
Invocation.PreservedAnyVal, Invocation.PreservedAnyRef

Value Summary
abstract val clazz : java.lang.Class[Any]
abstract val value : T
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
abstract val value : T

abstract val clazz : java.lang.Class[Any]