[project @ 2003-07-23 13:39:11 by simonmar]
[ghc-hetmet.git] / ghc / compiler / rename / RnIfaces.lhs
index 309ab65..e3aa3a4 100644 (file)
@@ -31,7 +31,7 @@ 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, nameIsLocalOrFrom, 
@@ -41,7 +41,6 @@ import NameSet
 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
 
 
@@ -477,6 +479,8 @@ getWiredInGates (AClass cl)
     super_classes = classNamesOfTheta (classSCTheta cl)
 
 getWiredInGates (AnId the_id) = tyClsNamesOfType (idType the_id)
+getWiredInGates (ADataCon dc) = tyClsNamesOfType (idType (dataConWrapId dc))
+       -- Should include classes in the 'stupid context' of the data con?
 getWiredInGates (ATyCon tc)
   | isSynTyCon tc = tyClsNamesOfType ty
   | otherwise    = unitFV (getName tc)