aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <unknown>2004-03-25 10:29:56 +0000
committersimonmar <unknown>2004-03-25 10:29:56 +0000
commit7b87344c5f8aa3017aa6aebc851ce14b7bee0696 (patch)
treee477fb0ab9b7cb32d95f36f458494d7652e8cbe5
parentf49aa7585acbf46686e4113168ddc89443e87cc2 (diff)
[haddock @ 2004-03-25 10:29:56 by simonmar]
If a name is imported from two places, one hidden and one not, choose the unhidden one to link to. Also, when there's only a hidden module to link to, don't try linking to it.
-rw-r--r--src/Main.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 9106bffb..28842d3c 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -882,8 +882,15 @@ buildImportEnv :: ModuleMap -> Module
-> [HsImportDecl] -- the import decls
-> FiniteMap HsQName HsQName
buildImportEnv mod_map this_mod exported_names imp_decls
- = foldr plusFM emptyFM (map build imp_decls)
+ = foldr (plusFM_C best_name) emptyFM (map build imp_decls)
where
+ -- choose qualified results over unqualified ones. In the future
+ -- we might make more intelligent decisions about which name to
+ -- link to.
+ best_name n@(Qual _ _) _ = n
+ best_name _ n@(Qual _ _) = n
+ best_name n _ = n
+
build imp_decl@(HsImportDecl _ mdl _ _ _) =
case lookupFM mod_map mdl of
Nothing -> emptyFM
@@ -900,6 +907,8 @@ buildImportEnv mod_map this_mod exported_names imp_decls
-- re-exported from the other module, but not documented there:
-- find the right place using the iface_reexported environment.
| Just new_qnm <- lookupFM reexport_env nm = new_qnm
+ -- if the destination is hidden, we have nowhere to link to
+ | OptHide `elem` iface_options iface = UnQual nm
-- otherwise, it's documented in the other module
| otherwise = Qual mdl nm