Skip to content

Commit 4a24f73

Browse files
committed
Add todo
1 parent f65d1b1 commit 4a24f73

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

compiler/src/dotty/tools/dotc/quoted/QuotePatterns.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object QuotePatterns:
5252
}
5353

5454
}.traverse(quotePattern.body)
55-
55+
// TODO-18271: Refactor this
5656
new tpd.TreeAccumulator[List[Symbol]] {
5757
override def apply(typevars: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] = tree match {
5858
case tree: SplicePattern =>

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,22 @@ class QuoteMatcher(debug: Boolean) {
442442
case TypeTreeTypeTest(pattern) if isSubTypeUnderEnv(scrutinee, pattern) => matched
443443
case _ => notMatched
444444

445+
// TODO-18271: We might want to restrict type bounds/type defs to match
446+
// only when they are empty bounds (<: Nothing :> Any)
447+
// to keep behavioral difference minimal
448+
case TypeBoundsTree(sclo, schi, scalias) =>
449+
println("trace: 19.1")
450+
pattern match
451+
case TypeBoundsTree(ptlo, pthi, ptalias) =>
452+
sclo =?= ptlo &&& schi =?= pthi &&& scalias =?= ptalias
453+
case _ => notMatched
454+
455+
case TypeDef(_, rhs1) =>
456+
println("trace: 19.2")
457+
pattern match
458+
case TypeDef(_, rhs2) => rhs1 =?= rhs2
459+
case _ => notMatched
460+
445461
/* Match val */
446462
case scrutinee @ ValDef(_, tpt1, _) =>
447463
pattern match
@@ -463,32 +479,13 @@ class QuoteMatcher(debug: Boolean) {
463479
notMatched
464480
case _ => matched
465481

466-
def matchTypeParams(ptparams: List[TypeDef], scparams: List[TypeDef]): optional[MatchingExprs] =
467-
// TODO-18271: Type bounds should be empty
468-
val ptsyms = ptparams.map(_.symbol)
469-
val scsyms = scparams.map(_.symbol)
470-
471-
ctx.gadtState.unifySyms(ptsyms, scsyms)
472-
matched
473-
474482
def matchParamss(scparamss: List[ParamClause], ptparamss: List[ParamClause])(using Env): optional[(Env, MatchingExprs)] =
475483
(scparamss, ptparamss) match {
476484
case (scparams :: screst, ptparams :: ptrest) =>
477-
(scparams, ptparams) match
478-
case (TypeDefs(scparams), TypeDefs(ptparams)) =>
479-
scparams.foreach(tdef => println(s"tdef.rhs = ${tdef.rhs.show}"))
480-
if scparams.exists(tdef => tdef.rhs.isEmpty) then
481-
notMatched
482-
483-
val newEnv = summon[Env] ++ scparams.map(_.symbol).zip(ptparams.map(_.symbol))
484-
val (resEnv, mrrest) = withEnv(newEnv)(matchParamss(screst, ptrest))
485-
(resEnv, mrrest)
486-
case (ValDefs(scparams), ValDefs(ptparams)) =>
487-
val mr1 = matchLists(scparams, ptparams)(_ =?= _)
488-
val newEnv = summon[Env] ++ scparams.map(_.symbol).zip(ptparams.map(_.symbol))
489-
val (resEnv, mrrest) = withEnv(newEnv)(matchParamss(screst, ptrest))
490-
(resEnv, mr1 &&& mrrest)
491-
case _ => notMatched
485+
val mr1 = matchLists(scparams, ptparams)(_ =?= _)
486+
val newEnv = summon[Env] ++ scparams.map(_.symbol).zip(ptparams.map(_.symbol))
487+
val (resEnv, mrrest) = withEnv(newEnv)(matchParamss(screst, ptrest))
488+
(resEnv, mr1 &&& mrrest)
492489
case (Nil, Nil) => (summon[Env], matched)
493490
case _ => notMatched
494491
}

0 commit comments

Comments
 (0)