Skip to content

Commit f75130d

Browse files
committed
Try unrolled inline loop for safety
1 parent cf4c07b commit f75130d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -454,20 +454,20 @@ class QuoteMatcher(debug: Boolean) {
454454
notMatched
455455
case _ => matched
456456

457-
/**
458-
* Implementation restriction: The current implementation matches type parameters
459-
* only when they have empty bounds (>: Nothing <: Any)
460-
*/
457+
/** Implementation restriction: The current implementation matches type parameters
458+
* only when they have empty bounds (>: Nothing <: Any)
459+
*/
461460
def matchTypeDef(sctypedef: TypeDef, pttypedef: TypeDef): MatchingExprs =
462-
sctypedef match
463-
case TypeDef(_, TypeBoundsTree(sclo, schi, EmptyTree))
464-
if sclo.tpe.isNothingType && schi.tpe.isAny =>
465-
pttypedef match
466-
case TypeDef(_, TypeBoundsTree(ptlo, pthi, EmptyTree))
467-
if ptlo.tpe.isNothingType && pthi.tpe.isAny =>
461+
inline def recur(tds: List[TypeDef], unwind: Int): MatchingExprs =
462+
if unwind == 0 then
468463
matched
469-
case _ => notMatched
470-
case _ => notMatched
464+
else
465+
tds.head match
466+
case TypeDef(_, TypeBoundsTree(lo, hi, EmptyTree))
467+
if lo.tpe.isNothingType && hi.tpe.isAny
468+
=> recur(tds.tail, unwind - 1)
469+
case _ => notMatched
470+
recur(sctypedef :: pttypedef :: Nil, unwind = 2)
471471

472472
def matchParamss(scparamss: List[ParamClause], ptparamss: List[ParamClause])(using Env): optional[(Env, MatchingExprs)] =
473473
(scparamss, ptparamss) match {

0 commit comments

Comments
 (0)