I have the following code and my issue is with the DropWhile Function for which the compiler complain and i can't really understand why, especially given the realease notes of scala 2.13.4 https://github.com/scala/scala/releases
sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[+A](head: A, tail: List[A]) extends List[A]
object List {
@tailrec
def dropWhile[A](list: List[A], f: A => Boolean): List[A] = list match {
case Nil => Nil
case Cons(s, xs) if f(s) => dropWhile(xs, f)
case Cons(s, xs) if !f(s) => xs
}
}
On line 35: warning: match may not be exhaustive. It would fail on the following input: Cons(_, _)
Is it a bug or limitation or am I not seeing something ?