The primary reason why quasiquotes don't work in this case is the fact that you don't match on a Tree
but rather a Type
. These two are separate concepts of the reflection API that are not quite the same.
A simple way to check if type is the same as the one you expect is to use typeOf
and type equality operator =:=
:
case tpe if tpe =:= typeOf[Unit] =>
Of course this is not the only way. One can also match through TypeRef
and check for equality of symbols inside of it as shown in other answers.