The main reason quasi-quarters do not work in this case is because you are not matching with Tree
, but rather with Type
. These two are separate concepts of the reflection API, which are not exactly the same.
An easy way to check if the type is the same as the one you expect is to use typeOf
and enter the equality operator =:=
:
case tpe if tpe =:= typeOf[Unit] =>
Of course, this is not the only way. You can also match TypeRef
and check for equality of characters inside it, as shown in other answers.
source share