[project @ 2003-05-06 10:25:32 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnIfaces.lhs
index 260981a..c0d97db 100644 (file)
@@ -31,17 +31,16 @@ import Id           ( idType, idName, globalIdDetails )
 import IdInfo          ( GlobalIdDetails(..) )
 import TcType          ( tyClsNamesOfType, classNamesOfTheta )
 import FieldLabel      ( fieldLabelTyCon )
-import DataCon         ( dataConTyCon )
+import DataCon         ( dataConTyCon, dataConWrapId )
 import TyCon           ( visibleDataCons, isSynTyCon, getSynTyConDefn, tyConClass_maybe, tyConName )
 import Class           ( className, classSCTheta )
-import Name            ( Name {-instance NamedThing-}, isWiredInName, isInternalName, nameModule, NamedThing(..)
-                        )
+import Name            ( Name {-instance NamedThing-}, isWiredInName, nameIsLocalOrFrom, 
+                         nameModule, NamedThing(..) )
 import NameEnv                 ( delFromNameEnv, lookupNameEnv )
 import NameSet
-import Module          ( Module, isHomeModule, extendModuleSet, moduleEnvElts )
+import Module          ( Module, isHomeModule )
 import PrelNames       ( hasKey, fractionalClassKey, numClassKey, 
                          integerTyConName, doubleTyConName )
-import FiniteMap
 import Outputable
 import Bag
 import Maybe( fromJust )
@@ -189,15 +188,18 @@ rnIfaceDecl rn (mod, decl) = initRn (InterfaceMode mod) (rn decl)
        -- Tiresomely, we must get the "main" name for the 
        -- thing, because that's what VSlurp contains, and what
        -- is recorded in the usage information
-get_main_name (AClass cl) = className cl
+get_main_name (AClass cl)   = className cl
+get_main_name (ADataCon dc) = tyConName (dataConTyCon dc)
 get_main_name (ATyCon tc)
   | Just clas <- tyConClass_maybe tc = get_main_name (AClass clas)
   | otherwise                       = tyConName tc
 get_main_name (AnId id)
   = case globalIdDetails id of
-       DataConId     dc -> get_main_name (ATyCon (dataConTyCon dc))
+       DataConWorkId dc -> get_main_name (ATyCon (dataConTyCon dc))
        DataConWrapId dc -> get_main_name (ATyCon (dataConTyCon dc))
        RecordSelId lbl  -> get_main_name (ATyCon (fieldLabelTyCon lbl))
+       GenericOpId tc   -> get_main_name (ATyCon tc)
+       ClassOpId cl     -> className cl
        other            -> idName id
 
 
@@ -233,7 +235,7 @@ importDecl already_slurped name
   =    -- STEP 0: Check if it's from this module
        -- Doing this catches a common case quickly
     getModule                          `thenM` \ this_mod ->
-    if isInternalName name || nameModule name == this_mod then
+    if nameIsLocalOrFrom this_mod name then
        -- Variables defined on the GHCi command line (e.g. let x = 3)
        -- are Internal names (which don't have a Module)
        returnM AlreadySlurped
@@ -477,6 +479,7 @@ getWiredInGates (AClass cl)
     super_classes = classNamesOfTheta (classSCTheta cl)
 
 getWiredInGates (AnId the_id) = tyClsNamesOfType (idType the_id)
+getWiredInGates (ADataCon dc) = tyClsNamesOfType (idType (dataConWrapId dc))
 getWiredInGates (ATyCon tc)
   | isSynTyCon tc = tyClsNamesOfType ty
   | otherwise    = unitFV (getName tc)
@@ -498,7 +501,7 @@ getImportedInstDecls gates
        old_gates = eps_inst_gates eps
        new_gates = gates `minusNameSet` old_gates
        all_gates = new_gates `unionNameSets` old_gates
-       orphan_mods = [mod | (mod, True, _) <- moduleEnvElts (dep_mods imports)]
+       orphan_mods = imp_orphs imports
     in
     loadOrphanModules orphan_mods                      `thenM_` 
 
@@ -535,8 +538,7 @@ getImportedRules slurped
   | otherwise
   = getEps             `thenM` \ eps ->
     getInGlobalScope   `thenM` \ in_type_env ->
-    let
-               -- Slurp rules for anything that is slurped, 
+    let                -- Slurp rules for anything that is slurped, 
                -- either now, or previously
        available n        = n `elemNameSet` slurped || in_type_env n
        (decls, new_rules) = selectGated available (eps_rules eps)
@@ -599,7 +601,7 @@ checkVersions source_unchanged iface
 
        -- Source code unchanged and no errors yet... carry on 
        -- First put the dependent-module info in the envt, just temporarily,
-       -- so that when we look for interfaces we look for the right one.
+       -- so that when we look for interfaces we look for the right one (.hi or .hi-boot)
        -- It's just temporary because either the usage check will succeed 
        -- (in which case we are done with this module) or it'll fail (in which
        -- case we'll compile the module from scratch anyhow).
@@ -609,7 +611,7 @@ checkVersions source_unchanged iface
 
   where
        -- This is a bit of a hack really
-    mod_deps = emptyImportAvails { dep_mods = mkModDeps (fst (mi_deps iface)) }
+    mod_deps = emptyImportAvails { imp_dep_mods = mkModDeps (dep_mods (mi_deps iface)) }
 
 checkList :: [TcRn m RecompileRequired] -> TcRn m RecompileRequired
 checkList []            = returnM upToDate