Scala3 macros: How to prove a generic type T is a specific type?

I’m currently mucking about with scala 3’s macros and specifically the ability to get a more specific type within a macro from a generic type…

def genPrnt[T](using tType: Type[T])(using Quotes): Expr[T => Unit] = 
  (t: T) => 
      '{t} match
        case '{$xT: X}=> '{println($xT)}

I would like to use this feature for specialization, however, in the above pattern, xT is not an Expr[X] but rather an Expr[X & T]. I would like a way to prove in my code that T == X, because a lot of the applications of specialization require a specific type, not a type that can be viewed as a type.

Right now, the cleanest working solution I’ve found is testing[X] ==[T]. This is a string comparison though and not quite what I hoped for. Is there a cleaner way to determine if T is X, not if T can be viewed as X?

1 Like

I think I found the solution today.

tType match
  case '[Int] => ...

Seems to do what I want