title: Scala 2.10.1 and specialization (can't get it working right)
body: <p>Sorry for asking second time about specialization, but I haven't good understanding of what the heck is going on yet...<br>
  So, I have one project (Gomoku game with AI), and I decided to use my own simple and dirty @specialized ad-hoc collections in the hot part of it, because I must store primitive types without boxing. The problem is that this doesn't really help, because in <code>jvisualvm</code>'s Sampler I clearly see</p>
  
  <pre><code>scala.runtime.BoxesRunTime.boxToShort()
  </code></pre>
  
  <p>eating up <em>thousands</em> of ms when the optimal move search starts running.</p>
  
  <p>The project: <a href="https://github.com/magicgoose/Gomoku" rel="nofollow">https://github.com/magicgoose/Gomoku</a><br>
  The file with the poor "collections": <a href="https://github.com/magicgoose/Gomoku/blob/master/src/magicgoose/gomoku/ai/SpecializedCollections.scala" rel="nofollow">https://github.com/magicgoose/Gomoku/blob/master/src/magicgoose/gomoku/ai/SpecializedCollections.scala</a><br>
  The method, which causes boxing (one of them, I think):</p>
  
  <pre><code>trait Indexed[@specialized T] extends Enumerable[T] {
    @inline def length: Int
    @inline def apply(i: Int): T
  // ...
    @inline final def findIndex(fun: T =&gt; Boolean) = {
      @tailrec def find(i: Int): Int = {
        if (i &lt; length) {
          if (fun(this(i))) i
          else find(i + 1)
        } else -1
      }
      find(0)
    }
  }
  </code></pre>
  
  <p>I have seen another project (debox: <a href="https://github.com/non/debox" rel="nofollow">https://github.com/non/debox</a>), which tries to accomplish the similar thing (data collections without primitive boxing), but I don't really understand how it is done there.</p>