Skip to content

Commit 948b9dd

Browse files
committed
Move extension methods near their modules
1 parent 258bb7f commit 948b9dd

File tree

1 file changed

+86
-86
lines changed

1 file changed

+86
-86
lines changed

library/src/scala/tasty/reflect/TypeOrBoundsOps.scala

+86-86
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ trait TypeOrBoundsOps extends Core {
8484
internal.matchConstantType(typeOrBounds).map(_.constant)
8585
}
8686

87+
given (self: ConstantType) {
88+
def constant(given ctx: Context): Constant = internal.ConstantType_constant(self)
89+
}
90+
8791
object IsTermRef {
8892
/** Matches any TermRef and returns it */
8993
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TermRef] =
@@ -97,6 +101,11 @@ trait TypeOrBoundsOps extends Core {
97101
internal.matchTermRef(typeOrBounds).map(x => (x.qualifier, x.name))
98102
}
99103

104+
given (self: TermRef) {
105+
def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TermRef_qualifier(self)
106+
def name(given ctx: Context): String = internal.TermRef_name(self)
107+
}
108+
100109
object IsTypeRef {
101110
/** Matches any TypeRef and returns it */
102111
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TypeRef] =
@@ -108,6 +117,11 @@ trait TypeOrBoundsOps extends Core {
108117
internal.matchTypeRef(typeOrBounds).map(x => (x.qualifier, x.name))
109118
}
110119

120+
given (self: TypeRef) {
121+
def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TypeRef_qualifier(self)
122+
def name(given ctx: Context): String = internal.TypeRef_name(self)
123+
}
124+
111125
object IsSuperType {
112126
/** Matches any SuperType and returns it */
113127
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[SuperType] =
@@ -119,6 +133,11 @@ trait TypeOrBoundsOps extends Core {
119133
internal.matchSuperType(typeOrBounds).map(x => (x.thistpe, x.supertpe))
120134
}
121135

136+
given (self: SuperType) {
137+
def thistpe(given ctx: Context): Type = internal.SuperType_thistpe(self)
138+
def supertpe(given ctx: Context): Type = internal.SuperType_supertpe(self)
139+
}
140+
122141
object IsRefinement {
123142
/** Matches any Refinement and returns it */
124143
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[Refinement] =
@@ -130,6 +149,12 @@ trait TypeOrBoundsOps extends Core {
130149
internal.matchRefinement(typeOrBounds).map(x => (x.parent, x.name, x.info))
131150
}
132151

152+
given (self: Refinement) {
153+
def parent(given ctx: Context): Type = internal.Refinement_parent(self)
154+
def name(given ctx: Context): String = internal.Refinement_name(self)
155+
def info(given ctx: Context): TypeOrBounds = internal.Refinement_info(self)
156+
}
157+
133158
object IsAppliedType {
134159
/** Matches any AppliedType and returns it */
135160
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AppliedType] =
@@ -143,6 +168,11 @@ trait TypeOrBoundsOps extends Core {
143168
internal.matchAppliedType(typeOrBounds).map(x => (x.tycon, x.args))
144169
}
145170

171+
given (self: AppliedType) {
172+
def tycon(given ctx: Context): Type = internal.AppliedType_tycon(self)
173+
def args(given ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self)
174+
}
175+
146176
object IsAnnotatedType {
147177
/** Matches any AnnotatedType and returns it */
148178
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AnnotatedType] =
@@ -154,6 +184,11 @@ trait TypeOrBoundsOps extends Core {
154184
internal.matchAnnotatedType(typeOrBounds).map(x => (x.underlying, x.annot))
155185
}
156186

187+
given (self: AnnotatedType) {
188+
def underlying(given ctx: Context): Type = internal.AnnotatedType_underlying(self)
189+
def annot(given ctx: Context): Term = internal.AnnotatedType_annot(self)
190+
}
191+
157192
object IsAndType {
158193
/** Matches any AndType and returns it */
159194
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AndType] =
@@ -165,6 +200,11 @@ trait TypeOrBoundsOps extends Core {
165200
internal.matchAndType(typeOrBounds).map(x => (x.left, x.right))
166201
}
167202

203+
given (self: AndType) {
204+
def left(given ctx: Context): Type = internal.AndType_left(self)
205+
def right(given ctx: Context): Type = internal.AndType_right(self)
206+
}
207+
168208
object IsOrType {
169209
/** Matches any OrType and returns it */
170210
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[OrType] =
@@ -176,6 +216,11 @@ trait TypeOrBoundsOps extends Core {
176216
internal.matchOrType(typeOrBounds).map(x => (x.left, x.right))
177217
}
178218

219+
given (self: OrType) {
220+
def left(given ctx: Context): Type = internal.OrType_left(self)
221+
def right(given ctx: Context): Type = internal.OrType_right(self)
222+
}
223+
179224
object IsMatchType {
180225
/** Matches any MatchType and returns it */
181226
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[MatchType] =
@@ -187,6 +232,12 @@ trait TypeOrBoundsOps extends Core {
187232
internal.matchMatchType(typeOrBounds).map(x => (x.bound, x.scrutinee, x.cases))
188233
}
189234

235+
given (self: MatchType) {
236+
def bound(given ctx: Context): Type = internal.MatchType_bound(self)
237+
def scrutinee(given ctx: Context): Type = internal.MatchType_scrutinee(self)
238+
def cases(given ctx: Context): List[Type] = internal.MatchType_cases(self)
239+
}
240+
190241
object IsByNameType {
191242
/** Matches any ByNameType and returns it */
192243
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ByNameType] =
@@ -198,6 +249,10 @@ trait TypeOrBoundsOps extends Core {
198249
internal.matchByNameType(typeOrBounds).map(_.underlying)
199250
}
200251

252+
given (self: ByNameType) {
253+
def underlying(given ctx: Context): Type = internal.ByNameType_underlying(self)
254+
}
255+
201256
object IsParamRef {
202257
/** Matches any ParamRef and returns it */
203258
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ParamRef] =
@@ -209,6 +264,11 @@ trait TypeOrBoundsOps extends Core {
209264
internal.matchParamRef(typeOrBounds).map(x => (x.binder, x.paramNum))
210265
}
211266

267+
given (self: ParamRef) {
268+
def binder(given ctx: Context): LambdaType[TypeOrBounds] = internal.ParamRef_binder(self)
269+
def paramNum(given ctx: Context): Int = internal.ParamRef_paramNum(self)
270+
}
271+
212272
object IsThisType {
213273
/** Matches any ThisType and returns it */
214274
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ThisType] =
@@ -220,6 +280,10 @@ trait TypeOrBoundsOps extends Core {
220280
internal.matchThisType(typeOrBounds).map(_.tref)
221281
}
222282

283+
given (self: ThisType) {
284+
def tref(given ctx: Context): Type = internal.ThisType_tref(self)
285+
}
286+
223287
object IsRecursiveThis {
224288
/** Matches any RecursiveThis and returns it */
225289
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveThis] =
@@ -231,6 +295,10 @@ trait TypeOrBoundsOps extends Core {
231295
internal.matchRecursiveThis(typeOrBounds).map(_.binder)
232296
}
233297

298+
given (self: RecursiveThis) {
299+
def binder(given ctx: Context): RecursiveType = internal.RecursiveThis_binder(self)
300+
}
301+
234302
object IsRecursiveType {
235303
/** Matches any RecursiveType and returns it */
236304
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveType] =
@@ -242,6 +310,10 @@ trait TypeOrBoundsOps extends Core {
242310
internal.matchRecursiveType(typeOrBounds).map(_.underlying)
243311
}
244312

313+
given (self: RecursiveType) {
314+
def underlying(given ctx: Context): Type = internal.RecursiveType_underlying(self)
315+
}
316+
245317
object IsMethodType {
246318
/** Matches any MethodType and returns it */
247319
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[MethodType] =
@@ -253,6 +325,14 @@ trait TypeOrBoundsOps extends Core {
253325
internal.matchMethodType(typeOrBounds).map(x => (x.paramNames, x.paramTypes, x.resType))
254326
}
255327

328+
given (self: MethodType) {
329+
def isImplicit: Boolean = internal.MethodType_isImplicit(self)
330+
def isErased: Boolean = internal.MethodType_isErased(self)
331+
def paramNames(given ctx: Context): List[String] = internal.MethodType_paramNames(self)
332+
def paramTypes(given ctx: Context): List[Type] = internal.MethodType_paramTypes(self)
333+
def resType(given ctx: Context): Type = internal.MethodType_resType(self)
334+
}
335+
256336
object IsPolyType {
257337
/** Matches any PolyType and returns it */
258338
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[PolyType] =
@@ -264,6 +344,12 @@ trait TypeOrBoundsOps extends Core {
264344
internal.matchPolyType(typeOrBounds).map(x => (x.paramNames, x.paramBounds, x.resType))
265345
}
266346

347+
given (self: PolyType) {
348+
def paramNames(given ctx: Context): List[String] = internal.PolyType_paramNames(self)
349+
def paramBounds(given ctx: Context): List[TypeBounds] = internal.PolyType_paramBounds(self)
350+
def resType(given ctx: Context): Type = internal.PolyType_resType(self)
351+
}
352+
267353
object IsTypeLambda {
268354
/** Matches any TypeLambda and returns it */
269355
def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TypeLambda] =
@@ -275,92 +361,6 @@ trait TypeOrBoundsOps extends Core {
275361
internal.matchTypeLambda(typeOrBounds).map(x => (x.paramNames, x.paramBounds, x.resType))
276362
}
277363

278-
given (self: ConstantType) {
279-
def constant(given ctx: Context): Constant = internal.ConstantType_constant(self)
280-
}
281-
282-
given (self: TermRef) {
283-
def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TermRef_qualifier(self)
284-
def name(given ctx: Context): String = internal.TermRef_name(self)
285-
}
286-
287-
given (self: TypeRef) {
288-
def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TypeRef_qualifier(self)
289-
def name(given ctx: Context): String = internal.TypeRef_name(self)
290-
}
291-
292-
given (self: SuperType) {
293-
def thistpe(given ctx: Context): Type = internal.SuperType_thistpe(self)
294-
def supertpe(given ctx: Context): Type = internal.SuperType_supertpe(self)
295-
}
296-
297-
given (self: Refinement) {
298-
def parent(given ctx: Context): Type = internal.Refinement_parent(self)
299-
def name(given ctx: Context): String = internal.Refinement_name(self)
300-
def info(given ctx: Context): TypeOrBounds = internal.Refinement_info(self)
301-
}
302-
303-
given (self: AppliedType) {
304-
def tycon(given ctx: Context): Type = internal.AppliedType_tycon(self)
305-
def args(given ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self)
306-
}
307-
308-
given (self: AnnotatedType) {
309-
def underlying(given ctx: Context): Type = internal.AnnotatedType_underlying(self)
310-
def annot(given ctx: Context): Term = internal.AnnotatedType_annot(self)
311-
}
312-
313-
given (self: AndType) {
314-
def left(given ctx: Context): Type = internal.AndType_left(self)
315-
def right(given ctx: Context): Type = internal.AndType_right(self)
316-
}
317-
318-
given (self: OrType) {
319-
def left(given ctx: Context): Type = internal.OrType_left(self)
320-
def right(given ctx: Context): Type = internal.OrType_right(self)
321-
}
322-
323-
given (self: MatchType) {
324-
def bound(given ctx: Context): Type = internal.MatchType_bound(self)
325-
def scrutinee(given ctx: Context): Type = internal.MatchType_scrutinee(self)
326-
def cases(given ctx: Context): List[Type] = internal.MatchType_cases(self)
327-
}
328-
329-
given (self: ByNameType) {
330-
def underlying(given ctx: Context): Type = internal.ByNameType_underlying(self)
331-
}
332-
333-
given (self: ParamRef) {
334-
def binder(given ctx: Context): LambdaType[TypeOrBounds] = internal.ParamRef_binder(self)
335-
def paramNum(given ctx: Context): Int = internal.ParamRef_paramNum(self)
336-
}
337-
338-
given (self: ThisType) {
339-
def tref(given ctx: Context): Type = internal.ThisType_tref(self)
340-
}
341-
342-
given (self: RecursiveThis) {
343-
def binder(given ctx: Context): RecursiveType = internal.RecursiveThis_binder(self)
344-
}
345-
346-
given (self: RecursiveType) {
347-
def underlying(given ctx: Context): Type = internal.RecursiveType_underlying(self)
348-
}
349-
350-
given (self: MethodType) {
351-
def isImplicit: Boolean = internal.MethodType_isImplicit(self)
352-
def isErased: Boolean = internal.MethodType_isErased(self)
353-
def paramNames(given ctx: Context): List[String] = internal.MethodType_paramNames(self)
354-
def paramTypes(given ctx: Context): List[Type] = internal.MethodType_paramTypes(self)
355-
def resType(given ctx: Context): Type = internal.MethodType_resType(self)
356-
}
357-
358-
given (self: PolyType) {
359-
def paramNames(given ctx: Context): List[String] = internal.PolyType_paramNames(self)
360-
def paramBounds(given ctx: Context): List[TypeBounds] = internal.PolyType_paramBounds(self)
361-
def resType(given ctx: Context): Type = internal.PolyType_resType(self)
362-
}
363-
364364
given (self: TypeLambda) {
365365
def paramNames(given ctx: Context): List[String] = internal.TypeLambda_paramNames(self)
366366
def paramBounds(given ctx: Context): List[TypeBounds] = internal.TypeLambda_paramBounds(self)

0 commit comments

Comments
 (0)