I'm not sure why the second one compiles, but I do know that it doesn't work!
scala> IndexedSeq(1,2, 3).toSeq match {
case a :: b :: c :: nil => println("toto");
}
| | scala.MatchError: Vector(1, 2, 3) (of class scala.collection.immutable.Vector)
If you want to pattern match a sequence, you either need to use +: as the joining operator, or use Seq(a,b,c) as the pattern to match. See this answer
The following all work as desired:
IndexedSeq(1,2, 3).toSeq match {
case Seq(a, b, c) => println("toto");
}
IndexedSeq(1,2, 3) match {
case Seq(a, b, c) => println("toto");
}
IndexedSeq(1,2, 3).toSeq match {
case a +: b +: c => println("toto");
}
IndexedSeq(1,2, 3) match {
case a +: b +: c => println("toto");
}