Fix type variable substitution in gen_Newtype_fam_insts
Previously, gen_Newtype_fam_insts
was substituting the type variable binders of a type family instance using substTyVars
, which failed to take type variable dependencies into account. There is similar code in GHC.Tc.TyCl.Class.tcATDefault
that does perform this substitution properly, so this patch:
- Factors out this code into a top-level
substATBndrs
function, and - Uses
substATBndrs
ingen_Newtype_fam_insts
.
Fixes #23329.