@@ -364,20 +364,22 @@ object QuoteMatcher {
364
364
case scrutinee @ DefDef (_, paramss1, tpt1, _) =>
365
365
pattern match
366
366
case pattern @ DefDef (_, paramss2, tpt2, _) =>
367
- // TODO 17105: "rhs" is no longer appropriate, let's rename...
368
- def defEnv : Env =
369
- val paramSyms : List [(Symbol , Symbol )] =
370
- for
371
- (clause1, clause2) <- paramss1.zip(paramss2)
372
- (param1, param2) <- clause1.zip(clause2)
373
- yield
374
- param1.symbol -> param2.symbol
375
- val oldEnv : Env = summon[Env ]
376
- val newEnv : List [(Symbol , Symbol )] = (scrutinee.symbol -> pattern.symbol) :: paramSyms
377
- oldEnv ++ newEnv
378
- matchLists(paramss1, paramss2)(_ =?= _)
379
- &&& withEnv(defEnv)(tpt1 =?= tpt2)
380
- &&& withEnv(defEnv)(scrutinee.rhs =?= pattern.rhs)
367
+ def matchParamss (scparamss : List [ParamClause ], ptparamss : List [ParamClause ])(using Env ): optional[(Env , MatchingExprs )] =
368
+ (scparamss, ptparamss) match {
369
+ case (scparams :: screst, ptparams :: ptrest) =>
370
+ val mr1 = matchLists(scparams, ptparams)(_ =?= _)
371
+ val newEnv = summon[Env ] ++ scparams.map(_.symbol).zip(ptparams.map(_.symbol))
372
+ val (resEnv, mrrest) = withEnv(newEnv)(matchParamss(screst, ptrest))
373
+ (resEnv, mr1 &&& mrrest)
374
+ case (Nil , Nil ) => (summon[Env ], matched)
375
+ case _ => notMatched
376
+ }
377
+
378
+ val (pEnv, pmatch) = matchParamss(paramss1, paramss2)
379
+ val defEnv = pEnv + (scrutinee.symbol -> pattern.symbol)
380
+ pmatch
381
+ &&& withEnv(defEnv)(tpt1 =?= tpt2)
382
+ &&& withEnv(defEnv)(scrutinee.rhs =?= pattern.rhs)
381
383
case _ => notMatched
382
384
383
385
case Closure (_, _, tpt1) =>
@@ -398,22 +400,6 @@ object QuoteMatcher {
398
400
case _ =>
399
401
notMatched
400
402
401
- if (debug && res == notMatched)
402
- val quotes = QuotesImpl ()
403
- println(
404
- s """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
405
- |Scrutinee
406
- | ${scrutinee.show}
407
- |did not match pattern
408
- | ${pattern.show}
409
- |
410
- |with environment: ${summon[Env ]}
411
- |
412
- |Scrutinee: ${quotes.reflect.Printer .TreeStructure .show(scrutinee.asInstanceOf )}
413
- |Pattern: ${quotes.reflect.Printer .TreeStructure .show(pattern.asInstanceOf )}
414
- |
415
- | """ .stripMargin)
416
-
417
403
res
418
404
end =?=
419
405
@@ -546,7 +532,7 @@ object QuoteMatcher {
546
532
val hoasClosure = Closure (meth, bodyFn)
547
533
new ExprImpl (hoasClosure, spliceScope)
548
534
549
- private inline def notMatched : optional[MatchingExprs ] =
535
+ private inline def notMatched [ T ] : optional[T ] =
550
536
optional.break()
551
537
552
538
private inline def matched : MatchingExprs =
0 commit comments