Skip to content
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

false positive "unreachable code" in pattern match #11649

msiegenthaler opened this issue Jul 23, 2019 · 1 comment


Copy link

commented Jul 23, 2019

The following code gives

[warn]       unreachable code
[warn]       L9:  case Box() => Left(1)

when compiled with scala 2.12.8

sealed trait Command { type Err }
final case class Kick() extends Command { type Err = String }
final case class Box() extends Command { type Err = Int }
def handle[E](cmd: Command {type Err = E}): Either[E, Unit] = cmd match {
  case Kick() => Left("a")
  case Box() => Left(1)

The code works as expected, covering both cases, but the compiler emits the false warning. Might be related to #10251, but I'm not sure and the code is a bit simpler, so it might help you tracking it down.


This comment has been minimized.

Copy link

commented Jul 23, 2019

same in 2.13.0

@SethTisue SethTisue added this to the Backlog milestone Jul 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.