I believe the reason is simply that you are using a Map[T, T]
which is not specialized.
Some illustration:
scala> class MyMap[A,B]
defined class MyMap
scala> def extractLoop[@specialized T](x: MyMap[T, T]) = {
| sys.error("TODO")
| }
<console>:8: warning: type T is unused or used in non-specializable positions.
def extractLoop[@specialized T](x: MyMap[T, T]) = {
^
extractLoop: [T](x: MyMap[T,T])Nothing
But if you specialize MyMap
for its two type parameters, you have no warning:
scala> class MyMap[@specialized A,@specialized B]
defined class MyMap
scala> def extractLoop[@specialized T](x: MyMap[T, T]) = {
| sys.error("TODO")
| }
extractLoop: [T](x: MyMap[T,T])Nothing