Don't typecheck too much (or too little) in DerivingVia (#16923)
Previously, GHC would typecheck the via
type once per class in a
deriving
clause, which caused the problems observed in #16923 (closed).
This patch restructures some of the functionality in TcDeriv
and
TcHsType
to avoid this problem. We now typecheck the via
type
exactly once per deriving
clause and then typecheck all of the
classes in the clause.
See Note [Don't typecheck too much in DerivingVia]
in TcDeriv
for the full details.
Fixes #16923 (closed).