Statement of the question
Consider a type T
that contains an abstract type member A
:
trait T {
type A
}
This is a compiler limitation; one cannot generally specialize on elements of a type parameter. However, the proposed trick is good enough for my purposes:
trait Types {
type A
type B
}
trait GenOps[@specialized A, @specialized B] {
...
}
trait Ops[T <: Types] extends GenOps[T#A, T#B]
This way the trait Ops
gets specialized because it inherits the specialized implementations in trait GenOps
. My motivation is that I want trait Ops
to take a single type parameter T
, rather than both T#A
and T#B
(this becomes necessary when Ops
also takes a higher kinded type that expects T
as a parameter).
I can't see how that could possibly work. Specialization is done when compiling the class, and, at that time, A
isn't known.