Given:
abstract class Quantity[A <: Quantity[A]]
sealed trait UnitOfMeasure[A]
class Time extends Quantity[Time]
object Minutes extends UnitOfMeasure[Time]
class PowerRamp extends Quantity[PowerRamp]
object KilowattsPerHour extends UnitOfMeasure[PowerRamp]
type Test[X <: UnitOfMeasure[?]] = X match
case UnitOfMeasure[t] => t
The following compiles:
summon[Test[Minutes.type] =:= Time]
summon[Test[KilowattsPerHour.type] =:= PowerRamp]
However if trait UnitOfMeasure
is declared:
sealed trait UnitOfMeasure[A <: Quantity[A]]
Both summons fail with:
Cannot prove that Test[Minutes.type] =:= Time.
Note: a match type could not be fully reduced:
trying to reduce Test[Minutes.type]
failed since selector Minutes.type
matches none of the cases
case UnitOfMeasure[t] => t
What am I doing wrong?