Commit 52eed22d authored by simonpj's avatar simonpj
Browse files

[project @ 2001-02-20 09:41:48 by simonpj]

Deprecations [HscTypes, MkIface, Rename, RnEnv, RnIfaces]
~~~~~~~~~~~~
* Arrange that a change in deprecations is treated as a 
  hi-file difference.

* Warn about deprecations at the usage site.  This entailed
  changing HscTypes.GlobalRdrEnv to include deprecations.
  While I was at it, I changed the range of GlobalRdrEnv 
  to a data type, GlobalRdrElt, instead a of a pair.
parent 5e624292
......@@ -34,7 +34,7 @@ module HscTypes (
InstEnv, ClsInstEnv, DFunId,
PackageInstEnv, PackageRuleBase,
GlobalRdrEnv, RdrAvailInfo, pprGlobalRdrEnv,
GlobalRdrEnv, GlobalRdrElt(..), RdrAvailInfo, pprGlobalRdrEnv,
-- Provenance
Provenance(..), ImportReason(..),
......@@ -328,6 +328,13 @@ lookupDeprec (DeprecAll txt) name = Just txt
lookupDeprec (DeprecSome env) name = case lookupNameEnv env name of
Just (_, txt) -> Just txt
Nothing -> Nothing
instance Eq Deprecations where
-- Used when checking whether we need write a new interface
NoDeprecs == NoDeprecs = True
(DeprecAll t1) == (DeprecAll t2) = t1 == t2
(DeprecSome e1) == (DeprecSome e2) = nameEnvElts e1 == nameEnvElts e2
d1 == d2 = False
\end{code}
......@@ -427,7 +434,6 @@ data PersistentCompilerState
pcs_PRS :: PersistentRenamerState
}
\end{code}
The @PersistentRenamerState@ persists across successive calls to the
......@@ -528,15 +534,18 @@ The GlobalRdrEnv gives maps RdrNames to Names. There is a separate
one for each module, corresponding to that module's top-level scope.
\begin{code}
type GlobalRdrEnv = RdrNameEnv [(Name,Provenance)] -- The list is because there may be name clashes
-- These only get reported on lookup,
-- not on construction
type GlobalRdrEnv = RdrNameEnv [GlobalRdrElt]
-- The list is because there may be name clashes
-- These only get reported on lookup, not on construction
data GlobalRdrElt = GRE Name Provenance (Maybe DeprecTxt)
-- The Maybe DeprecTxt tells whether this name is deprecated
pprGlobalRdrEnv env
= vcat (map pp (rdrEnvToList env))
where
pp (rn, nps) = ppr rn <> colon <+>
vcat [ppr n <+> pprNameProvenance n p | (n,p) <- nps]
vcat [ppr n <+> pprNameProvenance n p | (GRE n p _) <- nps]
\end{code}
The "provenance" of something says how it came to be in scope.
......
......@@ -29,8 +29,8 @@ import HscTypes ( VersionInfo(..), ModIface(..), ModDetails(..),
)
import CmdLineOpts
import Id ( Id, idType, idInfo, isImplicitId, isDictFunId,
idSpecialisation, setIdInfo, isLocalId, idName, hasNoBinding
import Id ( idType, idInfo, isImplicitId, isDictFunId,
idSpecialisation, isLocalId, idName, hasNoBinding
)
import Var ( isId )
import VarSet
......@@ -362,11 +362,13 @@ addVersionInfo Nothing new_iface
-- No old interface, so definitely write a new one!
= (new_iface, Just (text "No old interface available"))
addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
mi_decls = old_decls,
mi_fixities = old_fixities }))
new_iface@(ModIface { mi_decls = new_decls,
mi_fixities = new_fixities })
addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
mi_decls = old_decls,
mi_fixities = old_fixities,
mi_deprecs = old_deprecs }))
new_iface@(ModIface { mi_decls = new_decls,
mi_fixities = new_fixities,
mi_deprecs = new_deprecs })
| no_output_change && no_usage_change
= (new_iface, Nothing)
......@@ -384,11 +386,12 @@ addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
vers_rules = bumpVersion no_rule_change (vers_rules old_version),
vers_decls = tc_vers }
no_output_change = no_tc_change && no_rule_change && no_export_change
no_output_change = no_tc_change && no_rule_change && no_export_change && no_deprec_change
no_usage_change = mi_usages old_iface == mi_usages new_iface
no_export_change = mi_exports old_iface == mi_exports new_iface -- Kept sorted
no_rule_change = dcl_rules old_decls == dcl_rules new_decls -- Ditto
no_deprec_change = old_deprecs == new_deprecs
-- Fill in the version number on the new declarations by looking at the old declarations.
-- Set the flag if anything changes.
......@@ -399,6 +402,7 @@ addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
pp_diffs = vcat [pp_tc_diffs,
pp_change no_export_change "Export list",
pp_change no_rule_change "Rules",
pp_change no_deprec_change "Deprecations",
pp_change no_usage_change "Usages"]
pp_change True what = empty
pp_change False what = text what <+> ptext SLIT("changed")
......
......@@ -6,7 +6,6 @@
\begin{code}
module RnIfaces
(
getInterfaceExports,
recordLocalSlurps,
mkImportInfo,
......@@ -29,7 +28,7 @@ import RnHsSyn ( RenamedHsDecl, RenamedTyClDecl,
extractHsTyNames, extractHsCtxtTyNames,
tyClDeclFVs, ruleDeclFVs, instDeclFVs
)
import RnHiFiles ( tryLoadInterface, loadHomeInterface, loadInterface,
import RnHiFiles ( tryLoadInterface, loadHomeInterface,
loadOrphanModules
)
import RnSource ( rnTyClDecl, rnInstDecl, rnIfaceRuleDecl )
......@@ -61,24 +60,6 @@ import Util ( sortLt )
\end{code}
%*********************************************************
%* *
\subsection{Getting what a module exports}
%* *
%*********************************************************
@getInterfaceExports@ is called only for directly-imported modules.
\begin{code}
getInterfaceExports :: ModuleName -> WhereFrom -> RnMG (Module, [(ModuleName,Avails)])
getInterfaceExports mod_name from
= loadInterface doc_str mod_name from `thenRn` \ iface ->
returnRn (mi_module iface, mi_exports iface)
where
doc_str = sep [ppr mod_name, ptext SLIT("is directly imported")]
\end{code}
%*********************************************************
%* *
\subsection{Keeping track of what we've slurped, and version numbers}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment