Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created April 15, 2022 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/7b5837b4a636baf6aeb02bba192d602a to your computer and use it in GitHub Desktop.
Save xuwei-k/7b5837b4a636baf6aeb02bba192d602a to your computer and use it in GitHub Desktop.
sealed abstract class Y
class Y1 extends Y
class Y2 extends Y
sealed abstract class X[B](val value: Int)
case object X1 extends X[Y1](1)
case object X2 extends X[Y2](2)
object A {
val values: Seq[X[Y]] = ???
def get(value: Int): X[Y] = {
values.find(_.value == value) match {
case Some(v) => v
case _ => sys.error("not found")
}
}
}
[warn] 16 | case Some(v) => v
[warn] | ^^^^^^^
[warn] | Unreachable case
[warn] one warning found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment