Como faço para eliminar o tipo de apagamento no Scala? Ou, por que não consigo obter o parâmetro type das minhas coleções?

É um fato triste da vida no Scala que se você instanciar uma List [Int], você pode verificar se a sua instância é uma List, e você pode verificar se qualquer elemento individual dela é um Int, mas não que é uma List [ Int], como pode ser facilmente verificado:

scala> List(1,2,3) match {
     | case l : List[String] => println("A list of strings?!")
     | case _ => println("Ok")
     | }
warning: there were unchecked warnings; re-run with -unchecked for details
A list of strings?!

A opção -unchecked coloca a culpa diretamente no apagamento de tipos:

scala>  List(1,2,3) match {
     |  case l : List[String] => println("A list of strings?!")
     |  case _ => println("Ok")
     |  }
<console>:6: warning: non variable type-argument String in type pattern is unchecked since it is eliminated by erasure
        case l : List[String] => println("A list of strings?!")
                 ^
A list of strings?!

Por que isso e como posso contornar isso?

questionAnswers(11)

yourAnswerToTheQuestion