More refactoring in RnNames
[ghc-hetmet.git] / compiler / typecheck / TcRnDriver.lhs
index 8cb815f..6dfae44 100644 (file)
@@ -167,9 +167,11 @@ tcRnModule hsc_env hsc_src save_rn_syntax
         traceIf (text "rdr_env: " <+> ppr rdr_env) ;
        failIfErrsM ;
 
-               -- Load any orphan-module interfaces, so that
-               -- their rules and instance decls will be found
-       loadOrphanModules (imp_orphs imports) ;
+               -- Load any orphan-module and family instance-module
+               -- interfaces, so that their rules and instance decls will be
+               -- found.
+       loadOrphanModules (imp_orphs  imports) False ;
+       loadOrphanModules (imp_finsts imports) True  ;
 
        traceRn (text "rn1a") ;
                -- Rename and type check the declarations
@@ -480,7 +482,7 @@ checkHiBootIface :: TcGblEnv -> ModDetails -> TcM (LHsBinds Id)
 
 checkHiBootIface
        (TcGblEnv { tcg_insts = local_insts, tcg_fam_insts = local_fam_insts,
-                   tcg_type_env = local_type_env, tcg_imports = imports })
+                   tcg_type_env = local_type_env })
        (ModDetails { md_insts = boot_insts, md_fam_insts = boot_fam_insts,
                      md_types = boot_type_env })
   = do { traceTc (text "checkHiBootIface" <+> (ppr boot_type_env $$ ppr boot_insts)) ;
@@ -495,8 +497,11 @@ checkHiBootIface
        ; return (unionManyBags dfun_binds) }
   where
     check_one boot_thing
-      | no_check name
-      = return ()      
+      | isImplicitTyThing boot_thing = return ()
+      | name `elem` dfun_names       = return ()       
+      | isWiredInName name          = return ()        -- No checking for wired-in names.  In particular,
+                                                       -- 'error' is handled by a rather gross hack
+                                                       -- (see comments in GHC.Err.hs-boot)
       | Just real_thing <- lookupTypeEnv local_type_env name
       = do { let boot_decl = tyThingToIfaceDecl boot_thing
                 real_decl = tyThingToIfaceDecl real_thing
@@ -509,17 +514,6 @@ checkHiBootIface
       where
        name = getName boot_thing
 
-    avail_env = imp_parent imports
-    is_implicit name = case lookupNameEnv avail_env name of
-                         Just (AvailTC tc _) | tc /= name -> True
-                         _otherwise -> False
-
-    no_check name = isWiredInName name -- No checking for wired-in names.  In particular,
-                                       -- 'error' is handled by a rather gross hack
-                                       -- (see comments in GHC.Err.hs-boot)
-                 || name `elem` dfun_names
-                 || is_implicit name   -- Has a parent, which we'll check
-
     dfun_names = map getName boot_insts
 
     check_inst boot_inst
@@ -1098,9 +1092,12 @@ tcGetModuleExports :: Module -> TcM [AvailInfo]
 tcGetModuleExports mod = do
   let doc = ptext SLIT("context for compiling statements")
   iface <- initIfaceTcRn $ loadSysInterface doc mod
-  loadOrphanModules (dep_orphs (mi_deps iface))
+  loadOrphanModules (dep_orphs (mi_deps iface)) False 
                -- Load any orphan-module interfaces,
                -- so their instances are visible
+  loadOrphanModules (dep_finsts (mi_finsts iface)) True
+               -- Load any family instance-module interfaces,
+               -- so all family instances are visible
   ifaceExportNames (mi_exports iface)
 
 tcRnLookupRdrName :: HscEnv -> RdrName -> IO (Maybe [Name])