Here is a short example in Scala 3:
type Ext[S <: Seq[_]] = S match {
case Seq[t] => t
}
trait XX[A, B <: Seq[A]]
trait XX1[B <: Seq[_]] extends XX[Ext[B], B]
So far it appears to be working, but when combining with type class the mask started to peel off
implicitly[Ext[Seq[Int]] =:= Int] // e.scala: Cannot prove that e.Ext[Seq[Int]] =:= Int
It may be caused by a bug in compatibility between Scala type class & match types. At this moment, the only way to circumvent this appears to be not using match type. Is it possible in Scala 2 or Scala 3?
UPDATE 1: I have tried the following alternatives:
type Ext[S] = S match {
case Seq[t] => t
} // success!
type Ext[S <: Any] = S match {
case Seq[t] => t
} // success!
type Ext[S <: Seq[Any]] = S match {
case Seq[t] => t
} // same error
So I'm fairly certain this is a bug. Again, the problem is how to avoid using match type from the beginning?