= let doc = text "context for compiling expression"
in
loadInterface doc (moduleName scope_module) ImportByUser `thenRn` \ iface ->
- let rdr_env = mi_globals iface
+
+ -- If this is a module we previously compiled, then mi_globals will
+ -- have its top-level environment. If it is an imported module, then
+ -- we must invent a top-level environment from its exports.
+ let rdr_env | Just env <- mi_globals iface = env
+ | otherwise = mkIfaceGlobalRdrEnv (mi_exports iface)
+
print_unqual = unQualInScope rdr_env
in
checkErrsRn `thenRn` \ no_errs_so_far ->
mi_boot = False,
mi_orphan = panic "is_orphan",
mi_exports = my_exports,
- mi_globals = gbl_env,
+ mi_globals = Just gbl_env,
mi_fixities = fixities,
mi_deprecs = my_deprecs,
mi_decls = panic "mi_decls"
-- REPORT UNUSED NAMES, AND DEBUG DUMP
reportUnusedNames mod_iface print_unqualified
- imports full_avail_env
+ imports full_avail_env gbl_env
source_fvs2 rn_imp_decls `thenRn_`
-- NB: source_fvs2: include exports (else we get bogus
-- warnings of unused things) but not implicit FVs.
mi_boot = False, mi_orphan = pi_orphan iface,
mi_fixities = fix_env, mi_deprecs = deprec_env,
mi_decls = decls,
- mi_globals = mkIfaceGlobalRdrEnv avails
+ mi_globals = Nothing
}
in
returnRn mod_iface
reportUnusedNames :: ModIface -> PrintUnqualified
-> [RdrNameImportDecl]
-> AvailEnv
+ -> GlobalRdrEnv
-> NameSet -- Used in this module
-> [RenamedHsDecl]
-> RnMG ()
-reportUnusedNames my_mod_iface unqual imports avail_env
+reportUnusedNames my_mod_iface unqual imports avail_env gbl_env
used_names imported_decls
= warnUnusedModules unused_imp_mods `thenRn_`
warnUnusedLocalBinds bad_locals `thenRn_`
printMinimalImports this_mod unqual minimal_imports
where
this_mod = mi_module my_mod_iface
- gbl_env = mi_globals my_mod_iface
-- Now, a use of C implies a use of T,
-- if C was brought into scope by T(..) or T(C)