@@ -123,7 +123,7 @@ trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps w
123
123
}
124
124
125
125
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 {
127
127
case x : tpd.Bind if x.name.isTypeName => Some ((x.name.toString, x.body))
128
128
case _ => None
129
129
}
@@ -141,27 +141,33 @@ trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps w
141
141
142
142
def TypeBoundsTreeDeco (bounds : TypeBoundsTree ): TypeBoundsTreeAPI = new TypeBoundsTreeAPI {
143
143
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
146
146
}
147
147
148
148
object IsTypeBoundsTree extends IsTypeBoundsTreeExtractor {
149
149
def unapply (x : TypeOrBoundsTree )(implicit ctx : Context ): Option [TypeBoundsTree ] = x match {
150
150
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
+ }
151
158
case _ => None
152
159
}
153
160
}
154
161
155
162
object TypeBoundsTree extends TypeBoundsTreeExtractor {
156
163
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) )
158
165
case _ => None
159
166
}
160
167
}
161
168
162
169
object WildcardTypeTree extends WildcardTypeTreeExtractor {
163
170
def unapply (x : TypeOrBoundsTree )(implicit ctx : Context ): Boolean = x match {
164
- case x @ Trees .TypeTree () => x.tpe.isInstanceOf [Types .TypeBounds ]
165
171
case Trees .Ident (nme.WILDCARD ) => x.tpe.isInstanceOf [Types .TypeBounds ]
166
172
case _ => false
167
173
}
0 commit comments