import DynFlags ( DynFlag(..), GhcMode(..) )
import HsSyn ( IE(..), ieName, ImportDecl(..), LImportDecl,
import DynFlags ( DynFlag(..), GhcMode(..) )
import HsSyn ( IE(..), ieName, ImportDecl(..), LImportDecl,
- ForeignDecl(..), HsGroup(..), HsBindGroup(..),
- Sig(..), collectGroupBinders, tyClDeclNames
+ ForeignDecl(..), HsGroup(..), HsValBinds(..),
+ Sig(..), collectHsBindLocatedBinders, tyClDeclNames
-import Module ( Module, moduleUserString, unitModuleEnv,
+import Module ( Module, moduleString, unitModuleEnv,
lookupModuleEnv, moduleEnvElts, foldModuleEnv )
import Name ( Name, nameSrcLoc, nameOccName, nameModule, isWiredInName,
nameParent, nameParent_maybe, isExternalName,
isBuiltInSyntax )
import NameSet
import NameEnv
lookupModuleEnv, moduleEnvElts, foldModuleEnv )
import Name ( Name, nameSrcLoc, nameOccName, nameModule, isWiredInName,
nameParent, nameParent_maybe, isExternalName,
isBuiltInSyntax )
import NameSet
import NameEnv
-import OccName ( srcDataName, isTcOcc, occNameFlavour, OccEnv,
- mkOccEnv, lookupOccEnv, emptyOccEnv, extendOccEnv )
+import OccName ( srcDataName, isTcOcc, pprNonVarNameSpace,
+ occNameSpace,
+ OccEnv, mkOccEnv, lookupOccEnv, emptyOccEnv,
+ extendOccEnv )
import HscTypes ( GenAvailInfo(..), AvailInfo,
HomePackageTable, PackageIfaceTable,
unQualInScope,
import HscTypes ( GenAvailInfo(..), AvailInfo,
HomePackageTable, PackageIfaceTable,
unQualInScope,
ASSERT2( not (pkg `elem` dep_pkgs deps), ppr pkg <+> ppr (dep_pkgs deps) )
([], pkg : dep_pkgs deps)
ASSERT2( not (pkg `elem` dep_pkgs deps), ppr pkg <+> ppr (dep_pkgs deps) )
([], pkg : dep_pkgs deps)
- Just (is_hiding, ls) -- Imports are spec'd explicitly
- | not is_hiding -> Just (not (null ls))
- _ -> Nothing -- Everything is imported,
- -- (or almost everything [hiding])
+ Just (is_hiding, ls) -> not is_hiding && null ls
+ other -> False
-- unqual_avails is the Avails that are visible in *unqualified* form
-- We need to know this so we know what to export when we see
-- unqual_avails is the Avails that are visible in *unqualified* form
-- We need to know this so we know what to export when we see
; this_mod = tcg_mod gbl_env
; imports = emptyImportAvails {
imp_env = unitModuleEnv this_mod $
; this_mod = tcg_mod gbl_env
; imports = emptyImportAvails {
imp_env = unitModuleEnv this_mod $
; returnM (gbl_env { tcg_rdr_env = rdr_env',
tcg_imports = imports `plusImportAvails` tcg_imports gbl_env })
}
; returnM (gbl_env { tcg_rdr_env = rdr_env',
tcg_imports = imports `plusImportAvails` tcg_imports gbl_env })
}
-- Add the new locally-bound names one by one, checking for duplicates as
-- we do so. Remember that in Template Haskell the duplicates
-- might *already be* in the GlobalRdrEnv from higher up the module
-- Add the new locally-bound names one by one, checking for duplicates as
-- we do so. Remember that in Template Haskell the duplicates
-- might *already be* in the GlobalRdrEnv from higher up the module
- sig_hs_bndrs = [nm | HsBindGroup _ lsigs _ <- val_decls,
- L _ (Sig nm _) <- lsigs]
- val_hs_bndrs = collectGroupBinders val_decls
+ sig_hs_bndrs = [nm | L _ (TypeSig nm _) <- val_sigs]
+ val_hs_bndrs = collectHsBindLocatedBinders val_decls
, Just deprec_txt <- lookupDeprec hpt pit name
= setSrcSpan (importSpecLoc imp_spec) $
addWarn (sep [ptext SLIT("Deprecated use of") <+>
, Just deprec_txt <- lookupDeprec hpt pit name
= setSrcSpan (importSpecLoc imp_spec) $
addWarn (sep [ptext SLIT("Deprecated use of") <+>
reportUnusedNames :: Maybe [Located (IE RdrName)] -- Export list
-> TcGblEnv -> RnM ()
reportUnusedNames export_decls gbl_env
reportUnusedNames :: Maybe [Located (IE RdrName)] -- Export list
-> TcGblEnv -> RnM ()
reportUnusedNames export_decls gbl_env
; warnUnusedModules unused_imp_mods
; warnUnusedImports unused_imports
; warnDuplicateImports defined_and_used
; warnUnusedModules unused_imp_mods
; warnUnusedImports unused_imports
; warnDuplicateImports defined_and_used
-- See the type of the imp_mods for this triple
direct_import_mods = moduleEnvElts (imp_mods imports)
-- See the type of the imp_mods for this triple
direct_import_mods = moduleEnvElts (imp_mods imports)
--
-- BUG WARNING: does not deal correctly with multiple imports of the same module
-- becuase direct_import_mods has only one entry per module
--
-- BUG WARNING: does not deal correctly with multiple imports of the same module
-- becuase direct_import_mods has only one entry per module
- unused_imp_mods = [(mod,loc) | (mod,imp,loc) <- direct_import_mods,
+ unused_imp_mods = [(mod,loc) | (mod,no_imp,loc) <- direct_import_mods,