title: Serializable and AnyVal
body: <p>I am search for the right signature of a method that takes a function <strong>func</strong> and an argument <strong>arg</strong>, copies them over the network to a remote computer and returns the result. Currently the signature looks like this:</p>
  
  <pre><code>def invokeRemote[A,B](address: String, func: A =&gt; B, arg: A): B
  </code></pre>
  
  <p>The problem with this is that the method throws a NotSerializable Exception if the arguments are not Serializable or one of Java's primitive types.</p>
  
  <p>I came up with the following solution to catch this error at compile time ...</p>
  
  <pre><code>type Func = (A =&gt; B) with Serializable
  
  def invokeRemote[A &lt;: Serializable, B &lt;: Serializable](address: String, func: Func, arg: A): B
  </code></pre>
  
  <p>... but now it is not possible anymore to pass arguments of type <strong>AnyVal</strong> like <strong>Int</strong>, <strong>Float</strong> or <strong>Double</strong> which do not explicitly implement <em>Serializable</em>.</p>
  
  <p>How should the method signature look like such that it accepts only Serializable objects or objects of type AnyVal as argument?</p>