Here is a simple example of my intention:
sealed trait Col[V] {
trait Wrapper
}
object Col1 extends Col[Int]
object Col2 extends Col[Double]
type WOf[T <: Col[_] with Singleton] = T#Wrapper
this is an alternative (simpler & more generalisable) way of writing:
type WOf[T <: Col[_] with Singleton] = T match {
case Col1.type => Col1.Wrapper
case Col2.type => Col2.Wrapper
}
But the compiler won't let me:
[Error]
***.scala:25:42: T is not a legal path
since it is not a concrete type
So what is the correct way to write the kind WOf
?
UPDATE 1: I could speculate that Scala 3 can use this type constructor to represent an Eta-expanded polymorphic function of the following definition:
def wOf[T <: Col[_]](v: T): v.Wrapper = ???
I just don't know what it is, is there any reason Scala 3 will choose to make this kind definition only available for a very specific case?