Skip to content

Commit 279fc9f

Browse files
committed
wip
1 parent 122a86a commit 279fc9f

File tree

2 files changed

+45
-138
lines changed

2 files changed

+45
-138
lines changed

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

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
100100

101101
def copy(original: Tree)(name: String)(implicit ctx: Context): Ident =
102102
tpd.cpy.Ident(original)(name.toTermName)
103-
104-
def unapply(x: Term)(implicit ctx: Context): Option[String] = x match {
105-
case x: tpd.Ident if x.isTerm => Some(x.name.show)
106-
case _ => None
107-
}
108103
}
109104

110105
object Select extends SelectModule {
@@ -119,11 +114,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
119114

120115
def copy(original: Tree)(qualifier: Term, name: String)(implicit ctx: Context): Select =
121116
tpd.cpy.Select(original)(qualifier, name.toTermName)
122-
123-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, String)] = x match {
124-
case x: tpd.Select if x.isTerm => Some((x.qualifier, x.name.toString))
125-
case _ => None
126-
}
127117
}
128118

129119
object Literal extends LiteralModule {
@@ -133,11 +123,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
133123

134124
def copy(original: Tree)(constant: Constant)(implicit ctx: Context): Literal =
135125
tpd.cpy.Literal(original)(constant)
136-
137-
def unapply(x: Term)(implicit ctx: Context): Option[Constant] = x match {
138-
case Trees.Literal(const) => Some(const)
139-
case _ => None
140-
}
141126
}
142127

143128
object This extends ThisModule {
@@ -147,11 +132,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
147132

148133
def copy(original: Tree)(qual: Option[Id])(implicit ctx: Context): This =
149134
tpd.cpy.This(original)(qual.getOrElse(untpd.EmptyTypeIdent))
150-
151-
def unapply(x: Term)(implicit ctx: Context): Option[Option[Id]] = x match {
152-
case Trees.This(qual) => Some(optional(qual))
153-
case _ => None
154-
}
155135
}
156136

157137
object New extends NewModule {
@@ -160,11 +140,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
160140

161141
def copy(original: Tree)(tpt: TypeTree)(implicit ctx: Context): New =
162142
tpd.cpy.New(original)(tpt)
163-
164-
def unapply(x: Term)(implicit ctx: Context): Option[TypeTree] = x match {
165-
case x: tpd.New => Some(x.tpt)
166-
case _ => None
167-
}
168143
}
169144

170145
object NamedArg extends NamedArgModule {
@@ -174,11 +149,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
174149

175150
def copy(tree: NamedArg)(name: String, arg: Term)(implicit ctx: Context): NamedArg =
176151
tpd.cpy.NamedArg(tree)(name.toTermName, arg)
177-
178-
def unapply(x: Term)(implicit ctx: Context): Option[(String, Term)] = x match {
179-
case x: tpd.NamedArg if x.name.isInstanceOf[Names.TermName] => Some((x.name.toString, x.arg))
180-
case _ => None
181-
}
182152
}
183153

184154
object Apply extends ApplyModule {
@@ -188,11 +158,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
188158

189159
def copy(original: Tree)(fun: Term, args: List[Term])(implicit ctx: Context): Apply =
190160
tpd.cpy.Apply(original)(fun, args)
191-
192-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, List[Term])] = x match {
193-
case x: tpd.Apply => Some((x.fun, x.args))
194-
case _ => None
195-
}
196161
}
197162

198163
object TypeApply extends TypeApplyModule {
@@ -202,11 +167,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
202167

203168
def copy(original: Tree)(fun: Term, args: List[TypeTree])(implicit ctx: Context): TypeApply =
204169
tpd.cpy.TypeApply(original)(fun, args)
205-
206-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, List[TypeTree])] = x match {
207-
case x: tpd.TypeApply => Some((x.fun, x.args))
208-
case _ => None
209-
}
210170
}
211171

212172
object Super extends SuperModule {
@@ -215,11 +175,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
215175

216176
def copy(original: Tree)(qual: Term, mix: Option[Id])(implicit ctx: Context): Super =
217177
tpd.cpy.Super(original)(qual, mix.getOrElse(untpd.EmptyTypeIdent))
218-
219-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Option[Id])] = x match {
220-
case x: tpd.Super => Some((x.qual, if (x.mix.isEmpty) None else Some(x.mix)))
221-
case _ => None
222-
}
223178
}
224179

225180
object Typed extends TypedModule {
@@ -228,11 +183,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
228183

229184
def copy(original: Tree)(expr: Term, tpt: TypeTree)(implicit ctx: Context): Typed =
230185
tpd.cpy.Typed(original)(expr, tpt)
231-
232-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, TypeTree)] = x match {
233-
case x: tpd.Typed => Some((x.expr, x.tpt))
234-
case _ => None
235-
}
236186
}
237187

238188
object Assign extends AssignModule {
@@ -242,10 +192,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
242192
def copy(original: Tree)(lhs: Term, rhs: Term)(implicit ctx: Context): Assign =
243193
tpd.cpy.Assign(original)(lhs, rhs)
244194

245-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Term)] = x match {
246-
case x: tpd.Assign => Some((x.lhs, x.rhs))
247-
case _ => None
248-
}
249195
}
250196

251197
object Block extends BlockModule {
@@ -254,11 +200,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
254200

255201
def copy(original: Tree)(stats: List[Statement], expr: Term)(implicit ctx: Context): Block =
256202
tpd.cpy.Block(original)(stats, expr)
257-
258-
def unapply(x: Term)(implicit ctx: Context): Option[(List[Statement], Term)] = x match {
259-
case IsBlock(x) => Some((x.stats, x.expr))
260-
case _ => None
261-
}
262203
}
263204

264205
object Inlined extends InlinedModule {
@@ -267,12 +208,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
267208

268209
def copy(original: Tree)(call: Option[TermOrTypeTree], bindings: List[Definition], expansion: Term)(implicit ctx: Context): Inlined =
269210
tpd.cpy.Inlined(original)(call.getOrElse(tpd.EmptyTree), bindings.asInstanceOf[List[tpd.MemberDef]], expansion)
270-
271-
def unapply(x: Term)(implicit ctx: Context): Option[(Option[TermOrTypeTree], List[Statement], Term)] = x match {
272-
case x: tpd.Inlined =>
273-
Some((optional(x.call), x.bindings, x.expansion))
274-
case _ => None
275-
}
276211
}
277212

278213
object Lambda extends LambdaModule {
@@ -282,10 +217,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
282217
def copy(original: Tree)(meth: Tree, tpt: Option[TypeTree])(implicit ctx: Context): Lambda =
283218
tpd.cpy.Closure(original)(Nil, meth, tpt.getOrElse(tpd.EmptyTree))
284219

285-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Option[TypeTree])] = x match {
286-
case x: tpd.Closure => Some((x.meth, optional(x.tpt)))
287-
case _ => None
288-
}
289220
}
290221

291222
object If extends IfModule {
@@ -295,10 +226,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
295226
def copy(original: Tree)(cond: Term, thenp: Term, elsep: Term)(implicit ctx: Context): If =
296227
tpd.cpy.If(original)(cond, thenp, elsep)
297228

298-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Term, Term)] = x match {
299-
case x: tpd.If => Some((x.cond, x.thenp, x.elsep))
300-
case _ => None
301-
}
302229
}
303230

304231
object Match extends MatchModule {
@@ -307,11 +234,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
307234

308235
def copy(original: Tree)(selector: Term, cases: List[CaseDef])(implicit ctx: Context): Match =
309236
tpd.cpy.Match(original)(selector, cases)
310-
311-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, List[CaseDef])] = x match {
312-
case x: tpd.Match => Some((x.selector, x.cases))
313-
case _ => None
314-
}
315237
}
316238

317239
object Try extends TryModule {
@@ -320,11 +242,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
320242

321243
def copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(implicit ctx: Context): Try =
322244
tpd.cpy.Try(original)(expr, cases, finalizer.getOrElse(tpd.EmptyTree))
323-
324-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, List[CaseDef], Option[Term])] = x match {
325-
case x: tpd.Try => Some((x.expr, x.cases, optional(x.finalizer)))
326-
case _ => None
327-
}
328245
}
329246

330247
object Return extends ReturnModule {
@@ -333,11 +250,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
333250

334251
def copy(original: Tree)(expr: Term)(implicit ctx: Context): Return =
335252
tpd.cpy.Return(original)(expr, tpd.ref(ctx.owner))
336-
337-
def unapply(x: Term)(implicit ctx: Context): Option[Term] = x match {
338-
case x: tpd.Return => Some(x.expr)
339-
case _ => None
340-
}
341253
}
342254

343255
object Repeated extends RepeatedModule {
@@ -346,11 +258,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
346258

347259
def copy(original: Tree)(elems: List[Term], elemtpt: TypeTree)(implicit ctx: Context): Repeated =
348260
tpd.cpy.SeqLiteral(original)(elems, elemtpt)
349-
350-
def unapply(x: Tree)(implicit ctx: Context): Option[(List[Term], TypeTree)] = x match {
351-
case x: tpd.SeqLiteral => Some((x.elems, x.elemtpt))
352-
case _ => None
353-
}
354261
}
355262

356263
object SelectOuter extends SelectOuterModule {
@@ -360,15 +267,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
360267

361268
def copy(original: Tree)(qualifier: Term, name: String, levels: Int)(implicit ctx: Context): SelectOuter =
362269
tpd.cpy.Select(original)(qualifier, NameKinds.OuterSelectName(name.toTermName, levels))
363-
364-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Int, Type)] = x match {
365-
case x: tpd.Select =>
366-
x.name match {
367-
case NameKinds.OuterSelectName(_, levels) => Some((x.qualifier, levels, x.tpe.stripTypeVar))
368-
case _ => None
369-
}
370-
case _ => None
371-
}
372270
}
373271

374272
object While extends WhileModule {
@@ -377,11 +275,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
377275

378276
def copy(original: Tree)(cond: Term, body: Term)(implicit ctx: Context): While =
379277
tpd.cpy.WhileDo(original)(cond, body)
380-
381-
def unapply(x: Term)(implicit ctx: Context): Option[(Term, Term)] = x match {
382-
case x: tpd.WhileDo => Some((x.cond, x.body))
383-
case _ => None
384-
}
385278
}
386279
}
387280

0 commit comments

Comments
 (0)