Skip to content

Commit 418aa2b

Browse files
committed
Add missing TASTy Reflect type API
1 parent 63ee01a commit 418aa2b

File tree

8 files changed

+704
-29
lines changed

8 files changed

+704
-29
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/CoreImpl.scala

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ trait CoreImpl extends scala.tasty.reflect.Core {
7878
type ByName = tpd.ByNameTypeTree
7979
type LambdaTypeTree = tpd.LambdaTypeTree
8080
type Bind = tpd.Bind
81+
type Block = tpd.Block
8182
}
8283
type TypeBoundsTree = tpd.TypeBoundsTree
8384
type WildcardType = tpd.TypeTree
@@ -86,11 +87,26 @@ trait CoreImpl extends scala.tasty.reflect.Core {
8687
type NoPrefix = Types.NoPrefix.type
8788
type TypeBounds = Types.TypeBounds
8889
type Type = Types.Type
89-
type RecursiveType = Types.RecType
90-
type LambdaType[ParamInfo] = Types.LambdaType { type PInfo = ParamInfo }
91-
type MethodType = Types.MethodType
92-
type PolyType = Types.PolyType
93-
type TypeLambda = Types.TypeLambda
90+
type ConstantType = Types.ConstantType
91+
type SymRef = Types.NamedType
92+
type TermRef = Types.NamedType
93+
type TypeRef = Types.NamedType
94+
type SuperType = Types.SuperType
95+
type Refinement = Types.RefinedType
96+
type AppliedType = Types.AppliedType
97+
type AnnotatedType = Types.AnnotatedType
98+
type AndType = Types.AndType
99+
type OrType = Types.OrType
100+
type MatchType = Types.MatchType
101+
type ByNameType = Types.ExprType
102+
type ParamRef = Types.ParamRef
103+
type ThisType = Types.ThisType
104+
type RecursiveThis = Types.RecThis
105+
type RecursiveType = Types.RecType
106+
type LambdaType[ParamInfo] = Types.LambdaType { type PInfo = ParamInfo }
107+
type MethodType = Types.MethodType
108+
type PolyType = Types.PolyType
109+
type TypeLambda = Types.TypeLambda
94110

95111
type ImportSelector = untpd.Tree
96112

compiler/src/dotty/tools/dotc/tastyreflect/TypeOrBoundsOpsImpl.scala

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dotty.tools.dotc.tastyreflect
22

3-
import dotty.tools.dotc.core.{Names, Types}
3+
import dotty.tools.dotc.core.{Contexts, Names, Types}
44

55
trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreImpl {
66

@@ -41,13 +41,29 @@ trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreI
4141

4242
object Type extends TypeModule {
4343

44+
object IsConstantType extends IsConstantTypeModule {
45+
def unapply(tree: Tree)(implicit ctx: Context): Option[ConstantType] = ???
46+
}
47+
48+
def ConstantTypeDeco(x: ConstantType): ConstantTypeAPI = new ConstantTypeAPI {
49+
50+
}
51+
4452
object ConstantType extends ConstantTypeExtractor {
4553
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[Constant] = x match {
4654
case Types.ConstantType(value) => Some(value)
4755
case _ => None
4856
}
4957
}
5058

59+
object IsSymRef extends IsSymRefModule {
60+
def unapply(tree: Tree)(implicit ctx: Context): Option[SymRef] = ???
61+
}
62+
63+
def SymRefDeco(x: SymRef): SymRefAPI = new SymRefAPI {
64+
65+
}
66+
5167
object SymRef extends SymRefExtractor {
5268
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Symbol, TypeOrBounds /* Type | NoPrefix */)] = x match {
5369
case tp: Types.NamedType =>
@@ -59,6 +75,14 @@ trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreI
5975
}
6076
}
6177

78+
object IsTermRef extends IsTermRefModule {
79+
def unapply(tree: Tree)(implicit ctx: Context): Option[TermRef] = ???
80+
}
81+
82+
def TermRefDeco(x: TermRef): TermRefAPI = new TermRefAPI {
83+
84+
}
85+
6286
object TermRef extends TermRefExtractor {
6387
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)] = x match {
6488
case tp: Types.NamedType =>
@@ -70,6 +94,14 @@ trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreI
7094
}
7195
}
7296

97+
object IsTypeRef extends IsTypeRefModule {
98+
def unapply(tree: Tree)(implicit ctx: Context): Option[TypeRef] = ???
99+
}
100+
101+
def TypeRefDeco(x: TypeRef): TypeRefAPI = new TypeRefAPI {
102+
103+
}
104+
73105
object TypeRef extends TypeRefExtractor {
74106
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)] = x match {
75107
case tp: Types.NamedType =>
@@ -81,62 +113,134 @@ trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreI
81113
}
82114
}
83115

116+
object IsSuperType extends IsSuperTypeModule {
117+
def unapply(tree: Tree)(implicit ctx: Context): Option[SuperType] = ???
118+
}
119+
120+
def SuperTypeDeco(x: SuperType): SuperTypeAPI = new SuperTypeAPI {
121+
122+
}
123+
84124
object SuperType extends SuperTypeExtractor {
85125
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, Type)] = x match {
86126
case Types.SuperType(thistpe, supertpe) => Some(thistpe, supertpe)
87127
case _ => None
88128
}
89129
}
90130

131+
object IsRefinement extends IsRefinementModule {
132+
def unapply(tree: Tree)(implicit ctx: Context): Option[Refinement] = ???
133+
}
134+
135+
def RefinementDeco(x: Refinement): RefinementAPI = new RefinementAPI {
136+
137+
}
138+
91139
object Refinement extends RefinementExtractor {
92140
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)] = x match {
93141
case Types.RefinedType(parent, name, info) => Some(parent, name.toString, info)
94142
case _ => None
95143
}
96144
}
97145

146+
object IsAppliedType extends IsAppliedTypeModule {
147+
def unapply(tree: Tree)(implicit ctx: Context): Option[AppliedType] = ???
148+
}
149+
150+
def AppliedTypeDeco(x: AppliedType): AppliedTypeAPI = new AppliedTypeAPI {
151+
152+
}
153+
98154
object AppliedType extends AppliedTypeExtractor {
99155
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] = x match {
100156
case Types.AppliedType(tycon, args) => Some((tycon.stripTypeVar, args.map(_.stripTypeVar)))
101157
case _ => None
102158
}
103159
}
104160

161+
object IsAnnotatedType extends IsAnnotatedTypeModule {
162+
def unapply(tree: Tree)(implicit ctx: Context): Option[AnnotatedType] = ???
163+
}
164+
165+
def AnnotatedTypeDeco(x: AnnotatedType): AnnotatedTypeAPI = new AnnotatedTypeAPI {
166+
167+
}
168+
105169
object AnnotatedType extends AnnotatedTypeExtractor {
106170
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, Term)] = x match {
107171
case Types.AnnotatedType(underlying, annot) => Some((underlying.stripTypeVar, annot.tree))
108172
case _ => None
109173
}
110174
}
111175

176+
object IsAndType extends IsAndTypeModule {
177+
def unapply(tree: Tree)(implicit ctx: Context): Option[AndType] = ???
178+
}
179+
180+
def AndTypeDeco(x: AndType): AndTypeAPI = new AndTypeAPI {
181+
182+
}
183+
112184
object AndType extends AndTypeExtractor {
113185
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, Type)] = x match {
114186
case Types.AndType(left, right) => Some(left.stripTypeVar, right.stripTypeVar)
115187
case _ => None
116188
}
117189
}
118190

191+
object IsOrType extends IsOrTypeModule {
192+
def unapply(tree: Tree)(implicit ctx: Context): Option[OrType] = ???
193+
}
194+
195+
def OrTypeDeco(x: OrType): OrTypeAPI = new OrTypeAPI {
196+
197+
}
198+
119199
object OrType extends OrTypeExtractor {
120200
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, Type)] = x match {
121201
case Types.OrType(left, right) => Some(left.stripTypeVar, right.stripTypeVar)
122202
case _ => None
123203
}
124204
}
125205

206+
object IsMatchType extends IsMatchTypeModule {
207+
def unapply(tree: Tree)(implicit ctx: Context): Option[MatchType] = ???
208+
}
209+
210+
def MatchTypeDeco(x: MatchType): MatchTypeAPI = new MatchTypeAPI {
211+
212+
}
213+
126214
object MatchType extends MatchTypeExtractor {
127215
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(Type, Type, List[Type])] = x match {
128216
case Types.MatchType(bound, scrutinee, cases) => Some((bound, scrutinee, cases))
129217
case _ => None
130218
}
131219
}
132220

221+
object IsByNameType extends IsByNameTypeModule {
222+
def unapply(tree: Tree)(implicit ctx: Context): Option[ByNameType] = ???
223+
}
224+
225+
def ByNameTypeDeco(x: ByNameType): ByNameTypeAPI = new ByNameTypeAPI {
226+
227+
}
228+
133229
object ByNameType extends ByNameTypeExtractor {
134230
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[Type] = x match {
135231
case Types.ExprType(resType) => Some(resType.stripTypeVar)
136232
case _ => None
137233
}
138234
}
139235

236+
object IsParamRef extends IsParamRefModule {
237+
def unapply(tree: Tree)(implicit ctx: Context): Option[ParamRef] = ???
238+
}
239+
240+
def ParamRefDeco(x: ParamRef): ParamRefAPI = new ParamRefAPI {
241+
242+
}
243+
140244
object ParamRef extends ParamRefExtractor {
141245
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(LambdaType[TypeOrBounds], Int)] = x match {
142246
case Types.TypeParamRef(binder, idx) =>
@@ -148,41 +252,89 @@ trait TypeOrBoundsOpsImpl extends scala.tasty.reflect.TypeOrBoundsOps with CoreI
148252
}
149253
}
150254

255+
object IsThisType extends IsThisTypeModule {
256+
def unapply(tree: Tree)(implicit ctx: Context): Option[ThisType] = ???
257+
}
258+
259+
def ThisTypeDeco(x: ThisType): ThisTypeAPI = new ThisTypeAPI {
260+
261+
}
262+
151263
object ThisType extends ThisTypeExtractor {
152264
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[Type] = x match {
153265
case Types.ThisType(tp) => Some(tp)
154266
case _ => None
155267
}
156268
}
157269

270+
object IsRecursiveThis extends IsRecursiveThisModule {
271+
def unapply(tree: Tree)(implicit ctx: Context): Option[RecursiveThis] = ???
272+
}
273+
274+
def RecursiveThisDeco(x: RecursiveThis): RecursiveThisAPI = new RecursiveThisAPI {
275+
276+
}
277+
158278
object RecursiveThis extends RecursiveThisExtractor {
159279
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[RecursiveType] = x match {
160280
case Types.RecThis(binder) => Some(binder)
161281
case _ => None
162282
}
163283
}
164284

285+
object IsRecursiveType extends IsRecursiveTypeModule {
286+
def unapply(tree: Tree)(implicit ctx: Context): Option[RecursiveType] = ???
287+
}
288+
289+
def RecursiveTypeDeco(x: RecursiveType): RecursiveTypeAPI = new RecursiveTypeAPI {
290+
291+
}
292+
165293
object RecursiveType extends RecursiveTypeExtractor {
166294
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[Type] = x match {
167295
case tp: Types.RecType => Some(tp.underlying.stripTypeVar)
168296
case _ => None
169297
}
170298
}
171299

300+
object IsMethodType extends IsMethodTypeModule {
301+
def unapply(tree: Tree)(implicit ctx: Context): Option[MethodType] = ???
302+
}
303+
304+
def MethodTypeDeco(x: MethodType): MethodTypeAPI = new MethodTypeAPI {
305+
306+
}
307+
172308
object MethodType extends MethodTypeExtractor {
173309
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(List[String], List[Type], Type)] = x match {
174310
case x: MethodType => Some(x.paramNames.map(_.toString), x.paramInfos, x.resType)
175311
case _ => None
176312
}
177313
}
178314

315+
object IsPolyType extends IsPolyTypeModule {
316+
def unapply(tree: Tree)(implicit ctx: Context): Option[PolyType] = ???
317+
}
318+
319+
def PolyTypeDeco(x: PolyType): PolyTypeAPI = new PolyTypeAPI {
320+
321+
}
322+
179323
object PolyType extends PolyTypeExtractor {
180324
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(List[String], List[TypeBounds], Type)] = x match {
181325
case x: PolyType => Some(x.paramNames.map(_.toString), x.paramInfos, x.resType)
182326
case _ => None
183327
}
184328
}
185329

330+
object IsTypeLambda extends IsTypeLambdaModule {
331+
def unapply(tree: Tree)(implicit ctx: Context): Option[TypeLambda] = ???
332+
}
333+
334+
def TypeLambdaDeco(x: TypeLambda): TypeLambdaAPI = new TypeLambdaAPI {
335+
336+
}
337+
186338
object TypeLambda extends TypeLambdaExtractor {
187339
def unapply(x: TypeOrBounds)(implicit ctx: Context): Option[(List[String], List[TypeBounds], Type)] = x match {
188340
case x: TypeLambda => Some(x.paramNames.map(_.toString), x.paramInfos, x.resType)

0 commit comments

Comments
 (0)