Refactor kindGeneralize and friends.
Commit message:
Refactor kindGeneralize and friends.
This commit should have no change in behavior.(*)
The observation was that Note [Recipe for checking a signature]
says that every metavariable in a type-checked type must either
(A) be generalized
(B) be promoted
(C) be zapped.
Yet the code paths for doing these were all somewhat separate.
This led to some steps being skipped. This commit shores this
all up. The key innovation is TcHsType.kindGeneralizeSome, with
appropriate commentary.
Other changes:
* zonkPromoteType is now replaced by kindGeneralizeNone.
This might have a small performance degradation, because
zonkPromoteType zonked and promoted all at once. The new
code path promotes first, and then zonks.
* A call to kindGeneralizeNone was added in tcHsPartialSigType.
I think this was a lurking bug, because it did not follow
Note [Recipe for checking a signature]. I did not try to
come up with an example showing the bug. This is the (*)
above.
Because of this change, there is an error message regression
in partial-sigs/should_fail/T14040a. This problem isn't really
a direct result of this refactoring, but is a symptom of
something deeper. See #16775, which addresses the deeper
problem.
* I added a short-cut to quantifyTyVars, in case there's
nothing to quantify.
* There was a horribly-outdated Note that wasn't referred
to. Gone now.
* While poking around with T14040a, I discovered a small
mistake in the Coercion.simplifyArgsWorker. Easy to fix,
happily.