Created
April 15, 2022 08:40
-
-
Save xuwei-k/7b5837b4a636baf6aeb02bba192d602a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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