Open
Description
Compiler version
3.3.5
Minimized code
package com.example
object Repro {
sealed abstract class Listener[A]
final case class Empty[A]()
extends Listener[A]
final case class Waiting[A](next: Promise[A])
extends Listener[A]
def foo[A](l: Listener[A]): Unit = {
l match {
case Empty() => println("empty")
case w @ Waiting(_) => println(s"waiting: ${w.next}") // <-- HERE
}
}
def main(args: Array[String]): Unit = {
foo(Waiting(Promise()))
}
}
sealed trait Promise[A]
object Promise {
def apply[A](): Promise[A] = new PromiseImpl[A](null)
private[this] abstract class PromiseBase[A] extends Promise[A]
private[this] final class PromiseImpl[A](val st: Waiting[A]) extends PromiseBase[A]
private[this] final class Waiting[A]
}
Output
[warn] -- [E030] Match case Unreachable Warning: /home/.../Repro.scala:...
[warn] 33 | case w @ Waiting(_) => println(s"waiting: ${w.next}")
[warn] | ^^^^^^^^^^^^^^
[warn] | Unreachable case
[warn] Matching filters for @nowarn or -Wconf:
[warn] - id=E30
[warn] - name=MatchCaseUnreachable
[warn] one warning found
[info] running com.example.Repro
waiting: com.example.Promise$PromiseImpl@d3995d
Expectation
I'd expect no "Unreachable case" warning for a case which is reachable.