@@ -442,6 +442,22 @@ class QuoteMatcher(debug: Boolean) {
442
442
case TypeTreeTypeTest (pattern) if isSubTypeUnderEnv(scrutinee, pattern) => matched
443
443
case _ => notMatched
444
444
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
+
445
461
/* Match val */
446
462
case scrutinee @ ValDef (_, tpt1, _) =>
447
463
pattern match
@@ -463,32 +479,13 @@ class QuoteMatcher(debug: Boolean) {
463
479
notMatched
464
480
case _ => matched
465
481
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
-
474
482
def matchParamss (scparamss : List [ParamClause ], ptparamss : List [ParamClause ])(using Env ): optional[(Env , MatchingExprs )] =
475
483
(scparamss, ptparamss) match {
476
484
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)
492
489
case (Nil , Nil ) => (summon[Env ], matched)
493
490
case _ => notMatched
494
491
}
0 commit comments