我有一种resultType
. Context.this.type#c#universe#Type
我需要将它与Unit
类型相匹配。我试过
resultType match {
case q"Unit" => ...
}
但我想这Unit
只是一个明显不匹配的字符串文字。如何通过 quasiqotes 匹配类型?
我也试过
resultType match {
case TypeRef(ThisType(_), Symbol("scala.Unit"), _) => ...
}
但有一个错误:
[error] pattern type is incompatible with expected type;
[error] found : Symbol
[error] required: Context.this.c.universe.SymbolContextApi
如何以这种方式匹配类型?