@@ -368,7 +368,11 @@ private def checkHandlerTypeSubsumption
368
368
Set (Constraint .HandlerTypeSubsumption (Γ, handlerType1, handlerType2))
369
369
case (_ : ResolvedMetaVariable , _ : ResolvedMetaVariable ) =>
370
370
Set (Constraint .HandlerTypeSubsumption (Γ, handlerType1, handlerType2))
371
- case _ => throw NotHandlerTypeSubsumption (handlerType1, handlerType2)
371
+ case (sub : VTerm , sup : VTerm ) =>
372
+ val solvedSub = ctx.solveTerm(sub)
373
+ val solvedSup = ctx.solveTerm(sup)
374
+ if solvedSub == sub && solvedSup == sup then throw NotHandlerTypeSubsumption (sub, sup)
375
+ else checkHandlerTypeSubsumption(solvedSub, solvedSup)
372
376
373
377
@ throws(classOf [IrError ])
374
378
private def checkEqDecidabilitySubsumption
@@ -390,7 +394,11 @@ private def checkEqDecidabilitySubsumption
390
394
Set (Constraint .EqDecidabilitySubsumption (Γ, eqD1, eqD2))
391
395
case (_ : ResolvedMetaVariable , _ : ResolvedMetaVariable ) =>
392
396
Set (Constraint .EqDecidabilitySubsumption (Γ, eqD1, eqD2))
393
- case _ => throw NotEqDecidabilitySubsumption (eqD1, eqD2)
397
+ case (sub : VTerm , sup : VTerm ) =>
398
+ val solvedSub = ctx.solveTerm(sub)
399
+ val solvedSup = ctx.solveTerm(sup)
400
+ if solvedSub == sub && solvedSup == sup then throw NotEqDecidabilitySubsumption (sub, sup)
401
+ else checkEqDecidabilitySubsumption(solvedSub, solvedSup)
394
402
395
403
/** @param invert
396
404
* useful when checking patterns where the consumed usages are actually provided usages because
@@ -442,7 +450,11 @@ def checkUsageSubsumption
442
450
// hence we can't decide subsumption yet.
443
451
else if spuriousOperands.forall(isMeta) || operands1.exists(isMeta) then
444
452
Set (Constraint .UsageSubsumption (Γ, sub, sup))
445
- else throw NotUsageSubsumption (sub, sup)
453
+ else
454
+ val solvedSub = ctx.solveTerm(sub)
455
+ val solvedSup = ctx.solveTerm(sup)
456
+ if solvedSub == sub && solvedSup == sup then throw NotUsageSubsumption (sub, sup)
457
+ else checkUsageSubsumption(solvedSub, solvedSup)
446
458
// Handle the special case that the right hand side simply contains the left hand side as an operand.
447
459
case (UsageJoin (operands), RUnsolved (_, _, _, tm, _)) if operands.contains(Collapse (tm)) =>
448
460
Set .empty
@@ -512,11 +524,15 @@ def checkUsageSubsumption
512
524
Set (Constraint .UsageSubsumption (Γ, rawSub, sup))
513
525
case (_ : ResolvedMetaVariable , _ : ResolvedMetaVariable ) =>
514
526
Set (Constraint .UsageSubsumption (Γ, rawSub, rawSup))
515
- case _ =>
527
+ case ( sub : VTerm , sup : VTerm ) =>
516
528
if isMeta(rawSub) || isMeta(rawSup) then
517
529
// We can't decide if the terms are unsolved.
518
530
Set (Constraint .UsageSubsumption (Γ, rawSub, rawSup))
519
- else throw NotUsageSubsumption (rawSub, rawSup)
531
+ else
532
+ val solvedSub = ctx.solveTerm(sub)
533
+ val solvedSup = ctx.solveTerm(sup)
534
+ if solvedSub == sub && solvedSup == sup then throw NotUsageSubsumption (sub, sup)
535
+ else checkUsageSubsumption(solvedSub, solvedSup)
520
536
521
537
@ throws(classOf [IrError ])
522
538
private def checkEffSubsumption
@@ -600,15 +616,23 @@ private def checkEffSubsumption
600
616
).normalized
601
617
ctx.updateConstraint(u, UmcEffSubsumption (newLowerBound))
602
618
Set .empty
603
- case _ => throw NotEffectSubsumption (sub, sup)
619
+ case _ =>
620
+ val solvedSub = ctx.solveTerm(sub)
621
+ val solvedSup = ctx.solveTerm(sup)
622
+ if solvedSub == sub && solvedSup == sup then throw NotEffectSubsumption (sub, sup)
623
+ else checkEffSubsumption(solvedSub, solvedSup)
604
624
// If spurious operands are all stuck computation, it's possible for sub to be if all of these stuck computation
605
625
// ends up being assigned values that are part of sup
606
626
// Also, if sup contains stuck computation, it's possible for sup to end up including arbitrary effects and hence
607
627
// we can't decide subsumption yet.
608
628
else if spuriousOperands.keys.forall(isMeta) || unionOperands2.keys.exists(isMeta) then
609
629
Set (Constraint .EffSubsumption (Γ, sub, sup))
610
630
else throw NotEffectSubsumption (sub, sup)
611
- case _ => throw NotEffectSubsumption (rawSub, rawSup)
631
+ case (sub : VTerm , sup : VTerm ) =>
632
+ val solvedSub = ctx.solveTerm(sub)
633
+ val solvedSup = ctx.solveTerm(sup)
634
+ if solvedSub == sub && solvedSup == sup then throw NotEffectSubsumption (sub, sup)
635
+ else checkEffSubsumption(solvedSub, solvedSup)
612
636
613
637
/** Checks if l1 is smaller than l2.
614
638
*/
@@ -647,7 +671,11 @@ private def checkLevelSubsumption
647
671
// if sup contains unsolved meta variables, it's possible for sup to end up including
648
672
// arbitrary large level and hence we can't decide subsumption yet.
649
673
Set (Constraint .LevelSubsumption (Γ, sub, sup))
650
- else throw NotLevelSubsumption (sub, sup)
674
+ else
675
+ val solvedSub = ctx.solveTerm(sub)
676
+ val solvedSup = ctx.solveTerm(sup)
677
+ if solvedSub == sub && solvedSup == sup then throw NotLevelSubsumption (sub, sup)
678
+ else checkLevelSubsumption(solvedSub, solvedSup)
651
679
// Handle the special case that the right hand side simply contains the left hand side as an operand.
652
680
case (RUnsolved (_, _, _, tm, _), Level (_, operands)) if operands.contains(Collapse (tm)) =>
653
681
Set .empty
@@ -676,8 +704,11 @@ private def checkLevelSubsumption
676
704
Set (Constraint .LevelSubsumption (Γ, rawSub, sup))
677
705
case (_ : ResolvedMetaVariable , _ : ResolvedMetaVariable ) =>
678
706
Set (Constraint .LevelSubsumption (Γ, rawSub, rawSup))
679
- case (sub, sup) =>
680
- throw NotLevelSubsumption (rawSub, rawSup)
707
+ case (sub : VTerm , sup : VTerm ) =>
708
+ val solvedSub = ctx.solveTerm(sub)
709
+ val solvedSup = ctx.solveTerm(sup)
710
+ if solvedSub == sub && solvedSup == sup then throw NotLevelSubsumption (sub, sup)
711
+ else checkLevelSubsumption(solvedSub, solvedSup)
681
712
682
713
private def getSpurious [T , E : PartialOrdering ](sub : SeqMap [T , E ], sup : SeqMap [T , E ]): SeqMap [T , E ] =
683
714
sub.filter { case (operand1, e1) =>
0 commit comments