Skip to content

matchLocalInst: do domination analysis

sheaf requested to merge sheaf/ghc:T22216-v2 into master

This implements the domination test from #22216 (comment 454547):
when multiple quantified constraints match a Wanted, we now pick the one with the weakest precondition. For example:

  [G] Ord a => Eq (f a)
  [G] Eq  a => Eq (f a)
  [W] Eq (f a)

When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition.

This domination test is done purely using mkMinimalBySCs; it doesn't attempt to do a full round of constraint solving.

Edited by sheaf

Merge request reports