typelevel / cats

Lightweight, modular, and extensible library for functional programming.
https://typelevel.org/cats/
Other
5.26k stars 1.21k forks source link

Loss of type safety in scala 3 under certain conditions #4629

Closed jdrphillips closed 4 months ago

jdrphillips commented 4 months ago

Related to this behaviour in scala 3: https://github.com/scala/scala3/issues/20948

It means the following code compiles in scala 3:

NonEmptyList(5, Nil).contains(6)
NonEmptyList(5, Nil).contains("hello")

where in scala 2, the second line correctly does not compile.

Ideally the definition of contains (and other similar signatures?) would be changed to reintroduce the compilation error.

How to best achieve that I don't know