summaryrefslogtreecommitdiff
path: root/compiler/main/HscTypes.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main/HscTypes.hs')
-rw-r--r--compiler/main/HscTypes.hs63
1 files changed, 21 insertions, 42 deletions
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index ce5d37f00a..317a9413ec 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -451,7 +451,7 @@ instance Outputable TargetId where
-- | Helps us find information about modules in the home package
type HomePackageTable = ModuleNameEnv HomeModInfo
-- Domain = modules in the home package that have been fully compiled
- -- "home" package key cached here for convenience
+ -- "home" unit id cached here for convenience
-- | Helps us find information about modules in the imported packages
type PackageIfaceTable = ModuleEnv ModIface
@@ -683,7 +683,7 @@ type FinderCache = ModuleEnv FindResult
data FindResult
= Found ModLocation Module
-- ^ The module was found
- | NoPackage PackageKey
+ | NoPackage UnitId
-- ^ The requested package was not found
| FoundMultiple [(Module, ModuleOrigin)]
-- ^ _Error_: both in multiple packages
@@ -692,14 +692,14 @@ data FindResult
| NotFound
{ fr_paths :: [FilePath] -- Places where I looked
- , fr_pkg :: Maybe PackageKey -- Just p => module is in this package's
+ , fr_pkg :: Maybe UnitId -- Just p => module is in this package's
-- manifest, but couldn't find
-- the .hi file
- , fr_mods_hidden :: [PackageKey] -- Module is in these packages,
+ , fr_mods_hidden :: [UnitId] -- Module is in these packages,
-- but the *module* is hidden
- , fr_pkgs_hidden :: [PackageKey] -- Module is in these packages,
+ , fr_pkgs_hidden :: [UnitId] -- Module is in these packages,
-- but the *package* is hidden
, fr_suggestions :: [ModuleSuggestion] -- Possible mis-spelled modules
@@ -1123,7 +1123,7 @@ data CgGuts
-- as part of the code-gen of tycons
cg_foreign :: !ForeignStubs, -- ^ Foreign export stubs
- cg_dep_pkgs :: ![PackageKey], -- ^ Dependent packages, used to
+ cg_dep_pkgs :: ![UnitId], -- ^ Dependent packages, used to
-- generate #includes for C code gen
cg_hpc_info :: !HpcInfo, -- ^ Program coverage tick box information
cg_modBreaks :: !ModBreaks -- ^ Module breakpoints
@@ -1162,7 +1162,7 @@ as if they were defined in modules
interactive:Ghci2
...etc...
with each bunch of declarations using a new module, all sharing a
-common package 'interactive' (see Module.interactivePackageKey, and
+common package 'interactive' (see Module.interactiveUnitId, and
PrelNames.mkInteractiveModule).
This scheme deals well with shadowing. For example:
@@ -1454,7 +1454,7 @@ shadowed_by ids = shadowed
setInteractivePackage :: HscEnv -> HscEnv
-- Set the 'thisPackage' DynFlag to 'interactive'
setInteractivePackage hsc_env
- = hsc_env { hsc_dflags = (hsc_dflags hsc_env) { thisPackage = interactivePackageKey } }
+ = hsc_env { hsc_dflags = (hsc_dflags hsc_env) { thisPackage = interactiveUnitId } }
setInteractivePrintName :: InteractiveContext -> Name -> InteractiveContext
setInteractivePrintName ic n = ic{ic_int_print = n}
@@ -1538,20 +1538,13 @@ exposed (say P2), so we use M.T for that, and P1:M.T for the other one.
This is handled by the qual_mod component of PrintUnqualified, inside
the (ppr mod) of case (3), in Name.pprModulePrefix
-Note [Printing package keys]
+Note [Printing unit ids]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the old days, original names were tied to PackageIds, which directly
corresponded to the entities that users wrote in Cabal files, and were perfectly
suitable for printing when we need to disambiguate packages. However, with
-PackageKey, the situation is different. First, the key is not a human readable
-at all, so we need to consult the package database to find the appropriate
-PackageId to display. Second, there may be multiple copies of a library visible
-with the same PackageId, in which case we need to disambiguate. For now,
-we just emit the actual package key (which the user can go look up); however,
-another scheme is to (recursively) say which dependencies are different.
-
-NB: When we extend package keys to also have holes, we will have to disambiguate
-those as well.
+UnitId, the situation can be different: if the key is instantiated with
+some holes, we should try to give the user some more useful information.
-}
-- | Creates some functions that work out the best ways to format
@@ -1563,7 +1556,7 @@ mkPrintUnqualified dflags env = QueryQualify qual_name
where
qual_name mod occ
| [] <- unqual_gres
- , modulePackageKey mod `elem` [primPackageKey, basePackageKey, thPackageKey]
+ , moduleUnitId mod `elem` [primUnitId, baseUnitId, thUnitId]
, not (isDerivedOccName occ)
= NameUnqual -- For names from ubiquitous packages that come with GHC, if
-- there are no entities called unqualified 'occ', then
@@ -1609,10 +1602,10 @@ mkPrintUnqualified dflags env = QueryQualify qual_name
-- is only one exposed package which exports this module, don't qualify.
mkQualModule :: DynFlags -> QueryQualifyModule
mkQualModule dflags mod
- | modulePackageKey mod == thisPackage dflags = False
+ | moduleUnitId mod == thisPackage dflags = False
| [(_, pkgconfig)] <- lookup,
- packageConfigId pkgconfig == modulePackageKey mod
+ packageConfigId pkgconfig == moduleUnitId mod
-- this says: we are given a module P:M, is there just one exposed package
-- that exposes a module M, and is it package P?
= False
@@ -1622,10 +1615,10 @@ mkQualModule dflags mod
-- | Creates a function for formatting packages based on two heuristics:
-- (1) don't qualify if the package in question is "main", and (2) only qualify
--- with a package key if the package ID would be ambiguous.
+-- with a unit id if the package ID would be ambiguous.
mkQualPackage :: DynFlags -> QueryQualifyPackage
mkQualPackage dflags pkg_key
- | pkg_key == mainPackageKey || pkg_key == interactivePackageKey
+ | pkg_key == mainUnitId || pkg_key == interactiveUnitId
-- Skip the lookup if it's main, since it won't be in the package
-- database!
= False
@@ -2085,7 +2078,7 @@ data Dependencies
-- I.e. modules that this one imports, or that are in the
-- dep_mods of those directly-imported modules
- , dep_pkgs :: [(PackageKey, Bool)]
+ , dep_pkgs :: [(UnitId, Bool)]
-- ^ All packages transitively below this module
-- I.e. packages to which this module's direct imports belong,
-- or that are in the dep_pkgs of those modules
@@ -2407,9 +2400,9 @@ data ModSummary
-- ^ Timestamp of hi file, if we *only* are typechecking (it is
-- 'Nothing' otherwise.
-- See Note [Recompilation checking when typechecking only] and #9243
- ms_srcimps :: [Located (ImportDecl RdrName)],
+ ms_srcimps :: [(Maybe FastString, Located ModuleName)],
-- ^ Source imports of the module
- ms_textual_imps :: [Located (ImportDecl RdrName)],
+ ms_textual_imps :: [(Maybe FastString, Located ModuleName)],
-- ^ Non-source imports of the module from the module *text*
ms_merge_imps :: (Bool, [Module]),
-- ^ Non-textual imports computed for HsBootMerge
@@ -2425,26 +2418,12 @@ data ModSummary
ms_mod_name :: ModSummary -> ModuleName
ms_mod_name = moduleName . ms_mod
-ms_imps :: ModSummary -> [Located (ImportDecl RdrName)]
+ms_imps :: ModSummary -> [(Maybe FastString, Located ModuleName)]
ms_imps ms =
ms_textual_imps ms ++
map mk_additional_import (dynFlagDependencies (ms_hspp_opts ms))
where
- -- This is a not-entirely-satisfactory means of creating an import
- -- that corresponds to an import that did not occur in the program
- -- text, such as those induced by the use of plugins (the -plgFoo
- -- flag)
- mk_additional_import mod_nm = noLoc $ ImportDecl {
- ideclSourceSrc = Nothing,
- ideclName = noLoc mod_nm,
- ideclPkgQual = Nothing,
- ideclSource = False,
- ideclImplicit = True, -- Maybe implicit because not "in the program text"
- ideclQualified = False,
- ideclAs = Nothing,
- ideclHiding = Nothing,
- ideclSafe = False
- }
+ mk_additional_import mod_nm = (Nothing, noLoc mod_nm)
-- The ModLocation contains both the original source filename and the
-- filename of the cleaned-up source file after all preprocessing has been