Skip to content

Commit 7a1c9fd

Browse files
committed
Match erased parameters
1 parent 691eae0 commit 7a1c9fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ object QuoteMatcher {
383383
case scrutinee @ DefDef(_, paramss1, tpt1, _) =>
384384
pattern match
385385
case pattern @ DefDef(_, paramss2, tpt2, _) =>
386+
def matchErasedParams(scrutinee: DefDef, pattern: DefDef): optional[MatchingExprs] =
387+
(scrutinee.tpe.widenTermRefExpr, pattern.tpe.widenTermRefExpr) match
388+
case (sctpe: MethodType, pttpe: MethodType) =>
389+
if sctpe.erasedParams.sameElements(pttpe.erasedParams) then matched else notMatched
390+
case _ => notMatched
391+
386392
def matchParamss(scparamss: List[ParamClause], ptparamss: List[ParamClause])(using Env): optional[(Env, MatchingExprs)] =
387393
(scparamss, ptparamss) match {
388394
case (scparams :: screst, ptparams :: ptrest) =>
@@ -394,9 +400,12 @@ object QuoteMatcher {
394400
case _ => notMatched
395401
}
396402

403+
val ematch = matchErasedParams(scrutinee, pattern)
397404
val (pEnv, pmatch) = matchParamss(paramss1, paramss2)
398405
val defEnv = pEnv + (scrutinee.symbol -> pattern.symbol)
399-
pmatch
406+
407+
ematch
408+
&&& pmatch
400409
&&& withEnv(defEnv)(tpt1 =?= tpt2)
401410
&&& withEnv(defEnv)(scrutinee.rhs =?= pattern.rhs)
402411
case _ => notMatched

0 commit comments

Comments
 (0)