Skip to content

Commit 9df6f90

Browse files
committed
Simplify pattern
1 parent 3e2a7d5 commit 9df6f90

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
@@ -230,18 +230,18 @@ object QuoteMatcher {
230230
scrutinee =?= expr2
231231

232232
case _ =>
233-
(scrutinee, pattern) match
233+
scrutinee match
234234
/* Match type ascription (a) */
235-
case (Typed(expr1, _), _) =>
235+
case Typed(expr1, _) =>
236236
expr1 =?= pattern
237237

238238
/* Match literal */
239-
case (Literal(constant1), _) =>
239+
case Literal(constant1) =>
240240
pattern match
241241
case Literal(constant2) if constant1 == constant2 => matched
242242
case _ => notMatched
243243

244-
case (ref: RefTree, _) =>
244+
case ref: RefTree =>
245245
pattern match
246246
/* Match selection */
247247
case Select(qual2, _) if symbolMatch(scrutinee, pattern) =>
@@ -258,21 +258,21 @@ object QuoteMatcher {
258258
case _ => notMatched
259259

260260
/* Match application */
261-
case (Apply(fn1, args1), _) =>
261+
case Apply(fn1, args1) =>
262262
pattern match
263263
case Apply(fn2, args2) =>
264264
fn1 =?= fn2 &&& args1 =?= args2
265265
case _ => notMatched
266266

267267
/* Match type application */
268-
case (TypeApply(fn1, args1), _) =>
268+
case TypeApply(fn1, args1) =>
269269
pattern match
270270
case TypeApply(fn2, args2) =>
271271
fn1 =?= fn2 &&& args1 =?= args2
272272
case _ => notMatched
273273

274274
/* Match block */
275-
case (Block(stat1 :: stats1, expr1), _) =>
275+
case Block(stat1 :: stats1, expr1) =>
276276
pattern match
277277
case Block(stat2 :: stats2, expr2) =>
278278
val newEnv = (stat1, stat2) match {
@@ -287,65 +287,65 @@ object QuoteMatcher {
287287
case _ => notMatched
288288

289289
/* Match if */
290-
case (If(cond1, thenp1, elsep1), _) =>
290+
case If(cond1, thenp1, elsep1) =>
291291
pattern match
292292
case If(cond2, thenp2, elsep2) =>
293293
cond1 =?= cond2 &&& thenp1 =?= thenp2 &&& elsep1 =?= elsep2
294294
case _ => notMatched
295295

296296
/* Match while */
297-
case (WhileDo(cond1, body1), _) =>
297+
case WhileDo(cond1, body1) =>
298298
pattern match
299299
case WhileDo(cond2, body2) => cond1 =?= cond2 &&& body1 =?= body2
300300
case _ => notMatched
301301

302302
/* Match assign */
303-
case (Assign(lhs1, rhs1), _) =>
303+
case Assign(lhs1, rhs1) =>
304304
pattern match
305305
case Assign(lhs2, rhs2) => lhs1 =?= lhs2 &&& rhs1 =?= rhs2
306306
case _ => notMatched
307307

308308
/* Match new */
309-
case (New(tpt1), _) =>
309+
case New(tpt1) =>
310310
pattern match
311311
case New(tpt2) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol => matched
312312
case _ => notMatched
313313

314314
/* Match this */
315-
case (This(_), _) =>
315+
case This(_) =>
316316
pattern match
317317
case This(_) if scrutinee.symbol == pattern.symbol => matched
318318
case _ => notMatched
319319

320320
/* Match super */
321-
case (Super(qual1, mix1), _) =>
321+
case Super(qual1, mix1) =>
322322
pattern match
323323
case Super(qual2, mix2) if mix1 == mix2 => qual1 =?= qual2
324324
case _ => notMatched
325325

326326
/* Match varargs */
327-
case (SeqLiteral(elems1, _), _) =>
327+
case SeqLiteral(elems1, _) =>
328328
pattern match
329329
case SeqLiteral(elems2, _) if elems1.size == elems2.size => elems1 =?= elems2
330330
case _ => notMatched
331331

332332
/* Match type */
333333
// TODO remove this?
334-
case (TypeTreeTypeTest(scrutinee), _) =>
334+
case TypeTreeTypeTest(scrutinee) =>
335335
pattern match
336336
case TypeTreeTypeTest(pattern) if scrutinee.tpe <:< pattern.tpe => matched
337337
case _ => notMatched
338338

339339
/* Match val */
340-
case (scrutinee @ ValDef(_, tpt1, _), _) =>
340+
case scrutinee @ ValDef(_, tpt1, _) =>
341341
pattern match
342342
case pattern @ ValDef(_, tpt2, _) if checkValFlags() =>
343343
def rhsEnv = summon[Env] + (scrutinee.symbol -> pattern.symbol)
344344
tpt1 =?= tpt2 &&& withEnv(rhsEnv)(scrutinee.rhs =?= pattern.rhs)
345345
case _ => notMatched
346346

347347
/* Match def */
348-
case (scrutinee @ DefDef(_, paramss1, tpt1, _), _) =>
348+
case scrutinee @ DefDef(_, paramss1, tpt1, _) =>
349349
pattern match
350350
case pattern @ DefDef(_, paramss2, tpt2, _) =>
351351
def rhsEnv: Env =
@@ -363,17 +363,17 @@ object QuoteMatcher {
363363
&&& withEnv(rhsEnv)(scrutinee.rhs =?= pattern.rhs)
364364
case _ => notMatched
365365

366-
case (Closure(_, _, tpt1), _) =>
366+
case Closure(_, _, tpt1) =>
367367
pattern match
368368
case Closure(_, _, tpt2) => matched // TODO match tpt1 with tpt2?
369369
case _ => notMatched
370370

371-
case (NamedArg(name1, arg1), _) =>
371+
case NamedArg(name1, arg1) =>
372372
pattern match
373373
case NamedArg(name2, arg2) if name1 == name2 => arg1 =?= arg2
374374
case _ => notMatched
375375

376-
case (EmptyTree, _) =>
376+
case EmptyTree =>
377377
if pattern.isEmpty then matched
378378
else notMatched
379379

0 commit comments

Comments
 (0)