Add Exhaustivity Test for Enums with mixins
bishabosha opened this issue · 0 comments
bishabosha commented
sealed trait Pretty { self: Color => }
sealed trait Dull { self: Color => }
enum Color {
case Pink extends Color with Pretty
case Violet extends Colour with Pretty
case Red extends Color with Dull
}
def describe(c: Colour) = c match {
case Colour.Pink | Colour.Violet => "Pretty!"
case Colour.Red => "Dull!"
}
def describePartial(c: Colour) = c match { // error: would fail on case Red
case Colour.Pink | Colour.Violet => "Pretty!"
}
def describePretty(c: Pretty) = c match {
case Colour.Pink | Colour.Violet => "Pretty!"
case Colour.Red => "Pretty!" // error: Red not instance of Pretty
}
def describePrettyPartial(c: Pretty) = c match { // error: would fail on case Violet
case Colour.Pink => "Pretty!"
}
def describeDull(c: Dull) = c match {
case Colour.Pink => "Dull!" // error: Pink not instance of Dull
case Colour.Red => "Dull!"
}
from scala/scala3#8203