-importsFromLocalDecls :: HsGroup RdrName -> RnM TcGblEnv
-importsFromLocalDecls group
- = do { gbl_env <- getGblEnv
-
- ; avails <- getLocalDeclBinders gbl_env group
-
- ; rdr_env' <- extendRdrEnvRn (tcg_rdr_env gbl_env) avails
-
- ; traceRn (text "local avails: " <> ppr avails)
+extendGlobalRdrEnvRn :: Bool -- Note [Shadowing in extendGlobalRdrEnvRn]
+ -> [AvailInfo]
+ -> MiniFixityEnv
+ -> RnM (TcGblEnv, TcLclEnv)
+ -- Updates both the GlobalRdrEnv and the FixityEnv
+ -- We return a new TcLclEnv only becuase we might have to
+ -- delete some bindings from it; see Note [Shadowing in extendGlobalRdrEnvRn]
+
+extendGlobalRdrEnvRn shadowP avails new_fixities
+ = do { (gbl_env, lcl_env) <- getEnvs
+ ; let rdr_env = tcg_rdr_env gbl_env
+ fix_env = tcg_fix_env gbl_env
+
+ -- Delete new_occs from global and local envs
+ -- We are going to shadow them
+ -- See Note [Shadowing in extendGlobalRdrEnvRn]
+ new_occs = map (nameOccName . gre_name) gres
+ rdr_env1 = hideSomeUnquals rdr_env new_occs
+ lcl_env1 = lcl_env { tcl_rdr = delListFromOccEnv (tcl_rdr lcl_env) new_occs }
+
+ -- Note [Shadowing in extendGlobalRdrEnvRn]
+ (rdr_env2, lcl_env2) | shadowP = (rdr_env1, lcl_env1)
+ | otherwise = (rdr_env, lcl_env)