IfGblEnv(..), IfLclEnv(..),
-- Ranamer types
- ErrCtxt,
+ ErrCtxt, RecFieldEnv,
ImportAvails(..), emptyImportAvails, plusImportAvails,
WhereFrom(..), mkModDeps,
tcg_default :: Maybe [Type], -- Types used for defaulting
-- Nothing => no 'default' decl
- tcg_fix_env :: FixityEnv, -- Just for things in this module
+ tcg_fix_env :: FixityEnv, -- Just for things in this module
+ tcg_field_env :: RecFieldEnv, -- Just for things in this module
tcg_type_env :: TypeEnv, -- Global type env for the module we are compiling now
-- All TyCons and Classes (for this module) end up in here right away,
tcg_fords :: [LForeignDecl Id], -- ...Foreign import & exports
tcg_doc :: Maybe (HsDoc Name), -- Maybe Haddock documentation
- tcg_hmi :: HaddockModInfo Name -- Haddock module information
+ tcg_hmi :: HaddockModInfo Name, -- Haddock module information
+ tcg_hpc :: AnyHpcUsage -- True if any part of the prog uses hpc instrumentation.
}
+
+type RecFieldEnv = NameEnv [Name] -- Maps a constructor name *in this module*
+ -- to the fields for that constructor
+ -- This is used when dealing with ".." notation in record
+ -- construction and pattern matching.
+ -- The FieldEnv deals *only* with constructors defined in
+ -- *thie* module. For imported modules, we get the same info
+ -- from the TypeEnv
\end{code}
%************************************************************************
\begin{code}
data ImportAvails
= ImportAvails {
- imp_mods :: ModuleEnv (Module, Bool, SrcSpan),
+ imp_mods :: ModuleEnv (Module, [(ModuleName, Bool, SrcSpan)]),
-- Domain is all directly-imported modules
+ -- The ModuleName is what the module was imported as, e.g. in
+ -- import Foo as Bar
+ -- it is Bar.
-- Bool means:
-- True => import was "import Foo ()"
-- False => import was some other form
(ImportAvails { imp_mods = mods2,
imp_dep_mods = dmods2, imp_dep_pkgs = dpkgs2,
imp_orphs = orphs2, imp_finsts = finsts2 })
- = ImportAvails { imp_mods = mods1 `plusModuleEnv` mods2,
+ = ImportAvails { imp_mods = plusModuleEnv_C plus_mod mods1 mods2,
imp_dep_mods = plusUFM_C plus_mod_dep dmods1 dmods2,
imp_dep_pkgs = dpkgs1 `unionLists` dpkgs2,
imp_orphs = orphs1 `unionLists` orphs2,
imp_finsts = finsts1 `unionLists` finsts2 }
where
+ plus_mod (m1, xs1) (_, xs2) = (m1, xs1 ++ xs2)
plus_mod_dep (m1, boot1) (m2, boot2)
= WARN( not (m1 == m2), (ppr m1 <+> ppr m2) $$ (ppr boot1 <+> ppr boot2) )
-- Check mod-names match