@@ -123,7 +123,7 @@ trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps w
123123 }
124124
125125 object Bind extends BindExtractor {
126- def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeBoundsTree )] = x match {
126+ def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeOrBoundsTree )] = x match {
127127 case x : tpd.Bind if x.name.isTypeName => Some ((x.name.toString, x.body))
128128 case _ => None
129129 }
@@ -141,27 +141,33 @@ trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps w
141141
142142 def TypeBoundsTreeDeco (bounds : TypeBoundsTree ): TypeBoundsTreeAPI = new TypeBoundsTreeAPI {
143143 def tpe (implicit ctx : Context ): TypeBounds = bounds.tpe.asInstanceOf [Types .TypeBounds ]
144- def low (implicit ctx : Context ): TypeTree = bounds.asInstanceOf [tpd. TypeBoundsTree ]. lo
145- def hi (implicit ctx : Context ): TypeTree = bounds.asInstanceOf [tpd. TypeBoundsTree ]. hi
144+ def low (implicit ctx : Context ): TypeTree = bounds.lo
145+ def hi (implicit ctx : Context ): TypeTree = bounds.hi
146146 }
147147
148148 object IsTypeBoundsTree extends IsTypeBoundsTreeExtractor {
149149 def unapply (x : TypeOrBoundsTree )(implicit ctx : Context ): Option [TypeBoundsTree ] = x match {
150150 case x : tpd.TypeBoundsTree => Some (x)
151+ case x @ Trees .TypeTree () =>
152+ // TODO only enums generate this kind of type bounds. Is this possible without enums? If not generate tpd.TypeBoundsTree for enums instead
153+ x.tpe match {
154+ case tpe : Types .TypeBounds =>
155+ Some (tpd.TypeBoundsTree (tpd.TypeTree (tpe.lo).withPos(x.pos), tpd.TypeTree (tpe.hi).withPos(x.pos)))
156+ case _ => None
157+ }
151158 case _ => None
152159 }
153160 }
154161
155162 object TypeBoundsTree extends TypeBoundsTreeExtractor {
156163 def unapply (x : TypeOrBoundsTree )(implicit ctx : Context ): Option [(TypeTree , TypeTree )] = x match {
157- case x : tpd. TypeBoundsTree => Some (x.lo, x.hi)
164+ case IsTypeBoundsTree (x) => Some (( x.lo, x.hi) )
158165 case _ => None
159166 }
160167 }
161168
162169 object WildcardTypeTree extends WildcardTypeTreeExtractor {
163170 def unapply (x : TypeOrBoundsTree )(implicit ctx : Context ): Boolean = x match {
164- case x @ Trees .TypeTree () => x.tpe.isInstanceOf [Types .TypeBounds ]
165171 case Trees .Ident (nme.WILDCARD ) => x.tpe.isInstanceOf [Types .TypeBounds ]
166172 case _ => false
167173 }
0 commit comments