Pattern matcher unsoundness when mixing covariance and nonvariance #7952
Labels
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
patmat
Milestone
The following code will give a ClassCast exception.
Unfortunately, it looks like a difficult fix, because the obvious fix (require that the type parameter S is determined uniquely) would break all :: patterns, because List is declared to be covariant whereas :: is declared to be non-variant. Of course :: could and should have been declared covariant so there's no unsoundness problem for Lists themselves.
(JZ: edited to s/Some/::/)
The text was updated successfully, but these errors were encountered: