I’m using match types to implement rules for type promotion at the type level.
Here’s a simplified/minimized example (in reality there are more DTypes and we are combining multiple of them):
sealed abstract class DType
final class Int32 extends DType
val int32: Int32 = new Int32
type Promoted[A <: DType] <: DType = A match
case Int32 => Int32
case _ => DType
def f[A <: DType](a: A): Promoted[A] = a.asInstanceOf[Promoted[A]]
f(int32) // Int32
f(int32: DType) // Does not reduce: Promoted[DType]
f[DType](int32) // Does not reduce: Promoted[DType]
// We can still do an explicit type ascription:
f(int32: DType): DType // DType
Is there a way way to persuade the compiler to reduce to DType
somehow, or is this a fundamental restriction?