- other_fvs = plusFVs [src_fvs1, src_fvs2, src_fvs3, src_fvs4,
- src_fvs5, src_fvs6, src_fvs7] ;
- src_dus = bind_dus `plusDU` usesOnly other_fvs;
- -- Note: src_dus will contain *uses* for locally-defined types
- -- and classes, but no *defs* for them. (Because rnTyClDecl
- -- returns only the uses.) This is a little
- -- surprising but it doesn't actually matter at all.
-
- final_tcg_env = let tcg_env' = (tcg_env `addTcgDUs` src_dus)
- in -- we return the deprecs in the env, not in the HsGroup above
- tcg_env' { tcg_warns = tcg_warns tcg_env' `plusWarns` rn_warns };
+ tycl_bndrs = hsTyClDeclsBinders rn_tycl_decls rn_inst_decls ;
+ ford_bndrs = hsForeignDeclsBinders rn_foreign_decls ;
+ other_def = (Just (mkNameSet tycl_bndrs `unionNameSets` mkNameSet ford_bndrs), emptyNameSet) ;
+ other_fvs = plusFVs [src_fvs1, src_fvs2, src_fvs3, src_fvs4,
+ src_fvs5, src_fvs6, src_fvs7] ;
+ -- It is tiresome to gather the binders from type and class decls
+
+ src_dus = [other_def] `plusDU` bind_dus `plusDU` usesOnly other_fvs ;
+ -- Instance decls may have occurrences of things bound in bind_dus
+ -- so we must put other_fvs last
+
+ final_tcg_env = let tcg_env' = (tcg_env `addTcgDUs` src_dus)
+ in -- we return the deprecs in the env, not in the HsGroup above
+ tcg_env' { tcg_warns = tcg_warns tcg_env' `plusWarns` rn_warns };