Skip to content

Commit 95fad60

Browse files
committed
Simplify pattern
1 parent 7f6638f commit 95fad60

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

compiler/src/scala/quoted/runtime/impl/QuoteMatcher.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ object QuoteMatcher {
234234
scrutinee =?= expr2
235235

236236
case _ =>
237-
(scrutinee, pattern) match
237+
scrutinee match
238238
/* Match type ascription (a) */
239-
case (Typed(expr1, _), _) =>
239+
case Typed(expr1, _) =>
240240
expr1 =?= pattern
241241

242242
/* Match literal */
243-
case (Literal(constant1), _) =>
243+
case Literal(constant1) =>
244244
pattern match
245245
case Literal(constant2) if constant1 == constant2 => matched
246246
case _ => notMatched
247247

248-
case (ref: RefTree, _) =>
248+
case ref: RefTree =>
249249
pattern match
250250
/* Match selection */
251251
case Select(qual2, _) if symbolMatch(scrutinee, pattern) =>
@@ -262,21 +262,21 @@ object QuoteMatcher {
262262
case _ => notMatched
263263

264264
/* Match application */
265-
case (Apply(fn1, args1), _) =>
265+
case Apply(fn1, args1) =>
266266
pattern match
267267
case Apply(fn2, args2) =>
268268
fn1 =?= fn2 &&& args1 =?= args2
269269
case _ => notMatched
270270

271271
/* Match type application */
272-
case (TypeApply(fn1, args1), _) =>
272+
case TypeApply(fn1, args1) =>
273273
pattern match
274274
case TypeApply(fn2, args2) =>
275275
fn1 =?= fn2 &&& args1 =?= args2
276276
case _ => notMatched
277277

278278
/* Match block */
279-
case (Block(stat1 :: stats1, expr1), _) =>
279+
case Block(stat1 :: stats1, expr1) =>
280280
pattern match
281281
case Block(stat2 :: stats2, expr2) =>
282282
val newEnv = (stat1, stat2) match {
@@ -291,65 +291,65 @@ object QuoteMatcher {
291291
case _ => notMatched
292292

293293
/* Match if */
294-
case (If(cond1, thenp1, elsep1), _) =>
294+
case If(cond1, thenp1, elsep1) =>
295295
pattern match
296296
case If(cond2, thenp2, elsep2) =>
297297
cond1 =?= cond2 &&& thenp1 =?= thenp2 &&& elsep1 =?= elsep2
298298
case _ => notMatched
299299

300300
/* Match while */
301-
case (WhileDo(cond1, body1), _) =>
301+
case WhileDo(cond1, body1) =>
302302
pattern match
303303
case WhileDo(cond2, body2) => cond1 =?= cond2 &&& body1 =?= body2
304304
case _ => notMatched
305305

306306
/* Match assign */
307-
case (Assign(lhs1, rhs1), _) =>
307+
case Assign(lhs1, rhs1) =>
308308
pattern match
309309
case Assign(lhs2, rhs2) => lhs1 =?= lhs2 &&& rhs1 =?= rhs2
310310
case _ => notMatched
311311

312312
/* Match new */
313-
case (New(tpt1), _) =>
313+
case New(tpt1) =>
314314
pattern match
315315
case New(tpt2) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol => matched
316316
case _ => notMatched
317317

318318
/* Match this */
319-
case (This(_), _) =>
319+
case This(_) =>
320320
pattern match
321321
case This(_) if scrutinee.symbol == pattern.symbol => matched
322322
case _ => notMatched
323323

324324
/* Match super */
325-
case (Super(qual1, mix1), _) =>
325+
case Super(qual1, mix1) =>
326326
pattern match
327327
case Super(qual2, mix2) if mix1 == mix2 => qual1 =?= qual2
328328
case _ => notMatched
329329

330330
/* Match varargs */
331-
case (SeqLiteral(elems1, _), _) =>
331+
case SeqLiteral(elems1, _) =>
332332
pattern match
333333
case SeqLiteral(elems2, _) if elems1.size == elems2.size => elems1 =?= elems2
334334
case _ => notMatched
335335

336336
/* Match type */
337337
// TODO remove this?
338-
case (TypeTreeTypeTest(scrutinee), _) =>
338+
case TypeTreeTypeTest(scrutinee) =>
339339
pattern match
340340
case TypeTreeTypeTest(pattern) if scrutinee.tpe <:< pattern.tpe => matched
341341
case _ => notMatched
342342

343343
/* Match val */
344-
case (scrutinee @ ValDef(_, tpt1, _), _) =>
344+
case scrutinee @ ValDef(_, tpt1, _) =>
345345
pattern match
346346
case pattern @ ValDef(_, tpt2, _) if checkValFlags() =>
347347
def rhsEnv = summon[Env] + (scrutinee.symbol -> pattern.symbol)
348348
tpt1 =?= tpt2 &&& withEnv(rhsEnv)(scrutinee.rhs =?= pattern.rhs)
349349
case _ => notMatched
350350

351351
/* Match def */
352-
case (scrutinee @ DefDef(_, paramss1, tpt1, _), _) =>
352+
case scrutinee @ DefDef(_, paramss1, tpt1, _) =>
353353
pattern match
354354
case pattern @ DefDef(_, paramss2, tpt2, _) =>
355355
def rhsEnv: Env =
@@ -367,17 +367,17 @@ object QuoteMatcher {
367367
&&& withEnv(rhsEnv)(scrutinee.rhs =?= pattern.rhs)
368368
case _ => notMatched
369369

370-
case (Closure(_, _, tpt1), _) =>
370+
case Closure(_, _, tpt1) =>
371371
pattern match
372372
case Closure(_, _, tpt2) => matched // TODO match tpt1 with tpt2?
373373
case _ => notMatched
374374

375-
case (NamedArg(name1, arg1), _) =>
375+
case NamedArg(name1, arg1) =>
376376
pattern match
377377
case NamedArg(name2, arg2) if name1 == name2 => arg1 =?= arg2
378378
case _ => notMatched
379379

380-
case (EmptyTree, _) =>
380+
case EmptyTree =>
381381
if pattern.isEmpty then matched
382382
else notMatched
383383

0 commit comments

Comments
 (0)