[project @ 2005-04-28 16:05:54 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnNames.lhs
index 2b43899..e5052ce 100644 (file)
@@ -7,7 +7,7 @@
 module RnNames (
        rnImports, importsFromLocalDecls, 
        reportUnusedNames, reportDeprecations, 
-       mkModDeps, exportsToAvails, exportsFromAvail
+       mkModDeps, exportsFromAvail
     ) where
 
 #include "HsVersions.h"
@@ -18,7 +18,7 @@ import HsSyn          ( IE(..), ieName, ImportDecl(..), LImportDecl,
                          Sig(..), collectGroupBinders, tyClDeclNames 
                        )
 import RnEnv
-import IfaceEnv                ( lookupAvail )
+import IfaceEnv                ( ifaceExportNames )
 import LoadIface       ( loadSrcInterface )
 import TcRnMonad
 
@@ -34,7 +34,7 @@ import NameEnv
 import OccName         ( srcDataName, isTcOcc, occNameFlavour, OccEnv, 
                          mkOccEnv, lookupOccEnv, emptyOccEnv, extendOccEnv )
 import HscTypes                ( GenAvailInfo(..), AvailInfo,
-                         IfaceExport, HomePackageTable, PackageIfaceTable, 
+                         HomePackageTable, PackageIfaceTable, 
                          availNames, unQualInScope, 
                          Deprecs(..), ModIface(..), Dependencies(..), 
                          lookupIface, ExternalPackageState(..)
@@ -183,7 +183,7 @@ importsFromImportDecl this_mod
                                 is_loc = loc, is_as = qual_mod_name }
     in
        -- Get the total imports, and filter them according to the import list
-    exportsToAvails filtered_exports           `thenM` \ total_avails ->
+    ifaceExportNames filtered_exports          `thenM` \ total_avails ->
     filterImports iface imp_spec
                  imp_details total_avails      `thenM` \ (avail_env, gbl_env) ->
 
@@ -246,14 +246,6 @@ importsFromImportDecl this_mod
 
     returnM (gbl_env, imports)
 
-exportsToAvails :: [IfaceExport] -> TcRnIf gbl lcl NameSet
-exportsToAvails exports 
-  = foldlM do_one emptyNameSet exports
-  where
-    do_one acc (mod, exports)  = foldlM (do_avail mod) acc exports
-    do_avail mod acc avail = do { ns <- lookupAvail mod avail
-                               ; return (addListToNameSet acc ns) }
-
 warnRedundantSourceImport mod_name
   = ptext SLIT("Unnecessary {- SOURCE -} in the import of module")
           <+> quotes (ppr mod_name)
@@ -355,7 +347,7 @@ getLocalDeclBinders mod (HsGroup {hs_valds = val_decls,
     mappM new_tc     tycl_decls                                `thenM` \ tc_avails ->
        
        -- In a hs-boot file, the value binders come from the
-       -- *signatures*, and there should be no foreign binders 
+       --  *signatures*, and there should be no foreign binders 
     tcIsHsBoot                                         `thenM` \ is_hs_boot ->
     let val_bndrs | is_hs_boot = sig_hs_bndrs
                  | otherwise  = for_hs_bndrs ++ val_hs_bndrs
@@ -468,7 +460,7 @@ filterImports iface imp_spec (Just (want_hiding, import_items)) all_names
     get_item item@(IEThingAbs n)
       | want_hiding    -- hiding( C ) 
                        -- Here the 'C' can be a data constructor 
-                       -- *or* a type/class, or even both
+                       --  *or* a type/class, or even both
       = case concat [check_item item, check_item (IEVar data_n)] of
          []    -> bale_out item
          names -> succeed_with True names
@@ -614,6 +606,7 @@ filterAvail (IEThingWith _ rdrs) n subs
   where
     env = mkOccEnv [(nameOccName s, s) | s <- subNames subs n]
     mb_names = map (lookupOccEnv env . rdrNameOcc) rdrs
+filterAvail (IEModuleContents _) _ _ = panic "filterAvail"
 
 subNames :: NameEnv [Name] -> Name -> [Name]
 subNames env n = lookupNameEnv env n `orElse` []
@@ -882,6 +875,8 @@ warnDuplicateImports gres
     warn (GRE { gre_name = name, gre_prov = Imported imps _ })
        = addWarn ((quotes (ppr name) <+> ptext SLIT("is imported more than once:")) 
               $$ nest 2 (vcat (map ppr imps)))
+    warn gre = panic "warnDuplicateImports"
+       -- The GREs should all have Imported provenance
                              
 
 -- ToDo: deal with original imports with 'qualified' and 'as M' clauses