Closed
Description
Compiler version
3.1.1
Minimized code
Here is a Scastie.
The exhaustivity check fails when instances of Schema are defined in a trait.
sealed trait Schema[A]
object Schema extends RecordInstances
sealed trait RecordInstances:
case class Field[A]() extends Schema[A]
case object Thing extends Schema[Int]
import Schema._
// Match not exhaustive error! (with fatal warnings :P)
def handle[A](schema: Schema[A]) =
schema match
case Field() => println("field")
case Thing => println("thing")
Expectation
While it is a bit odd to define these instances in a trait, I would still expect this to correctly check exhaustivity. Scala 2 works as expected here.