Exhaustivity warning on opaque type

Hello everyone!

I’m getting an exhaustivity warning when matching on Message | Int, where Message is an opaque type.

Writing the TypeTest boilerplate was already cumbersome, but even with it defined, the compiler reports the match is not exhaustive for _: Package.Message.

[Scala 3.7.4]

Reproduction:

object Package:
  opaque type Message = String
  object Message:
    def apply(msg: String): Message = msg

  given scala.reflect.TypeTest[Any, Message] with
    def unapply(msg: Any): Option[msg.type & String] = msg match
      case s: (String & msg.type) => Some(s)
      case _                      => None

@main def main(): Unit =
  import Package.*

  def get: Message | Int = Message("test")

  get match
    case i: Int     => println(i)
    case s: Message => println(s)

Warning:

get match
^^^
match may not be exhaustive.

It would fail on pattern case: _: Package.Message