import TcTyClsDecls ( tcTyAndClassDecls )
import LoadIface ( loadOrphanModules )
import RnNames ( importsFromLocalDecls, rnImports, rnExports,
+ mkRdrEnvAndImports, mkExportNameSet,
reportUnusedNames, reportDeprecations )
import RnEnv ( lookupSrcOcc_maybe )
import RnSource ( rnSrcDecls, rnTyClDecls, checkModDeprec )
-> Located (HsModule RdrName)
-> IO (Messages, Maybe TcGblEnv)
-tcRnModule hsc_env hsc_src save_rn_decls
+tcRnModule hsc_env hsc_src save_rn_syntax
(L loc (HsModule maybe_mod export_ies
import_decls local_decls mod_deprec))
= do { showPass (hsc_dflags hsc_env) "Renamer/typechecker" ;
initTc hsc_env hsc_src this_mod $
setSrcSpan loc $
do {
- -- Deal with imports; sets tcg_rdr_env, tcg_imports
- (rdr_env, imports) <- rnImports import_decls ;
+ -- Deal with imports;
+ rn_imports <- rnImports import_decls ;
+ (rdr_env, imports) <- mkRdrEnvAndImports rn_imports ;
let { dep_mods :: ModuleEnv (Module, IsBootInterface)
; dep_mods = imp_dep_mods imports
gbl { tcg_rdr_env = rdr_env,
tcg_inst_env = extendInstEnvList (tcg_inst_env gbl) home_insts,
tcg_imports = tcg_imports gbl `plusImportAvails` imports,
- tcg_rn_decls = if save_rn_decls then
+ tcg_rn_imports = if save_rn_syntax then
+ Just rn_imports
+ else
+ Nothing,
+ tcg_rn_decls = if save_rn_syntax then
Just emptyRnGroup
else
Nothing })
reportDeprecations tcg_env ;
-- Process the export list
- exports <- rnExports (isJust maybe_mod) export_ies ;
+ rn_exports <- rnExports export_ies ;
+ let { liftM2' fn a b = do a' <- a; b' <- b; return (fn a' b') } ;
+ exports <- mkExportNameSet (isJust maybe_mod) (liftM2' (,) rn_exports export_ies) ;
-- Check whether the entire module is deprecated
-- This happens only once per module
-- Add exports and deprecations to envt
let { final_env = tcg_env { tcg_exports = exports,
+ tcg_rn_exports = if save_rn_syntax then
+ rn_exports
+ else Nothing,
tcg_dus = tcg_dus tcg_env `plusDU` usesOnly exports,
tcg_deprecs = tcg_deprecs tcg_env `plusDeprecs`
mod_deprecs }
checkMain :: TcM TcGblEnv
-- If we are in module Main, check that 'main' is defined.
checkMain
- = do { ghci_mode <- getGhciMode ;
+ = do { ghc_mode <- getGhcMode ;
tcg_env <- getGblEnv ;
dflags <- getDOpts ;
let { main_mod = mainModIs dflags ;
Just fn -> mkRdrUnqual (mkVarOccFS (mkFastString fn)) ;
Nothing -> main_RDR_Unqual } } ;
- check_main ghci_mode tcg_env main_mod main_fn
+ check_main ghc_mode tcg_env main_mod main_fn
}
-check_main ghci_mode tcg_env main_mod main_fn
+check_main ghc_mode tcg_env main_mod main_fn
| mod /= main_mod
= traceTc (text "checkMain not" <+> ppr main_mod <+> ppr mod) >>
return tcg_env
where
mod = tcg_mod tcg_env
- complain_no_main | ghci_mode == Interactive = return ()
+ complain_no_main | ghc_mode == Interactive = return ()
| otherwise = failWithTc noMainMsg
-- In interactive mode, don't worry about the absence of 'main'
-- In other modes, fail altogether, so that we don't go on