I develop a scala macro annotation that enriches objects with various definitions (cf. play form macro). Amongst other things I want that the object contains the type alias
type WFS = FS[_, _, _, _]
for a varying number of wildcard arguments.
I already tried to extract the value of a single wildcard type by
q"type WFS = FS[_]" match { q"type WFS = FS[$t]" => t }
and hoped to use the extracted value in a list of type parameters (e.g. q"type WFS = FS[..$tplist]"). Yet the above statement yields an error:
scala> q"type WFS = FS[_]" match { case q"type WFS = FS[$t]" => t }
scala.MatchError: type WFS = FS[_$1] forSome {
<synthetic> type _$1 >: _root_.scala.Nothing <: _root_.scala.Any
} (of class scala.reflect.internal.Trees$TypeDef)
at .<init>(<console>:15)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43
Is there another - maybe simpler - way to construct the necessary tree?