Skip to content

Add Exhaustivity Test for Enums with mixins #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bishabosha opened this issue Feb 7, 2020 · 0 comments · Fixed by #75
Closed

Add Exhaustivity Test for Enums with mixins #43

bishabosha opened this issue Feb 7, 2020 · 0 comments · Fixed by #75
Labels
good first issue topic:tasty/scala2 Scala 2 implementation of TASTy unpicking

Comments

@bishabosha
Copy link
Member

bishabosha commented Feb 7, 2020

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

@bishabosha bishabosha added the topic:tasty/scala2 Scala 2 implementation of TASTy unpicking label Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue topic:tasty/scala2 Scala 2 implementation of TASTy unpicking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant