Ok, without checking, what do you think happens? (List(0): Seq[Int]) match { case _: List[Int] => 1 case _ => 2 }
If `collection.mutable._` were imported, that would do it... but I doubt that's where the idea came from. Note that mutable.Seq[T] <:< Seq[T] which means that you can pass a mutable sequence to a method which requests an immutable one. Could that be the source of confusion?
-
-
It's related - the Seq type that's in scope by default is defined here: https://www.scala-lang.org/api/2.10.3/#scala.package … That's an alias for scala.collection.Seq, which is the supertype of both mutable and immutable. Meaning that you think your method expects an immutable Seq, but gets a mutable one.
-
Not sure why I linked the 2.10 doc, that's still the case in 2.12: https://www.scala-lang.org/api/2.12.12/scala/index.html#Seq[+A]=Seq[A …]
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.