Int and Char scala interpolation (generics and upper bounds)
<p>I am playing with generics and upper bounds in scala and I am facing the following problem:</p>

<p>Let's say I have the following function (where I only expect either Int or Char):</p>

<pre><code>def foo[T](tuple: Tuple2[T, T]) = tuple match {
  case Tuple2(x: Int, y: Int) =&gt; (x to y).toArray
  case Tuple2(x: Char, y: Char) =&gt; (x to y).toArray
}
</code></pre>

<p>I would expect to have a better and compressed form like:</p>

<pre><code>def foo2[T &gt;: Int with Char &lt;: AnyVal](tuple: (T, T))  = (tuple._1 to tuple._2).toArray
</code></pre>

<p>But this is definitely not working.</p>

<p>Any ideas?</p>