Instantiate top level foralls in partial type signatures
The main fix for #21667 (closed) is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before.
I also moved the decision about whether we need to apply the
Monomorphism Restriction, from decideGeneralisationPlan
to
tcPolyInfer
. That removes a flag from the InferGen constructor,
which is good.
But more importantly, it allows the new function,
checkMonomorphismRestriction
called from tcPolyInfer
, to "see" the Types
involved rather than
the HsTypes
. And that in turn matters because we invoke the MR for
partial signatures if none of the partial signatures in the group have
any overloading context; and we can't answer that question for HsTypes.
See Note [Partial type signatures and the monomorphism restriction]
in GHC.Tc.Gen.Bind.
This latter is really a pre-existing bug.