Note [Setting the argument context]
Consider we are doing the ambiguity check for the (bogus)
f :: (forall a b. C b => a -> a) -> Int
We'll call
tcSubType ((forall a b. C b => a->a) -> Int )
((forall a b. C b => a->a) -> Int )
with a UserTypeCtxt of (FunSigCtxt "f"). Then we'll do the co/contra thing
on the argument type of the (->) -- and at that point we want to switch
to a UserTypeCtxt of GenSigCtxt. Why?
* Error messages. If we stick with FunSigCtxt we get errors like
* Could not deduce: C b
from the context: C b0
bound by the type signature for:
f :: forall a b. C b => a->a
But of course f does not have that type signature!
Example tests: T10508, T7220a, Simple14
* Implications. We may decide to build an implication for the whole
ambiguity check, but we don't need one for each level within it,
and TcUnify.alwaysBuildImplication checks the UserTypeCtxt.
See Note [When to build an implication] References 1
- When to build an implication GHC.Tc.Utils.Unify
Referenced by 1
- GHC.Tc.Utils.Unify call site