[project @ 2000-11-20 16:07:12 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / Rename.lhs
index afc43b6..41abf2e 100644 (file)
@@ -22,7 +22,7 @@ import RnMonad
 import RnExpr          ( rnExpr )
 import RnNames         ( getGlobalNames, exportsFromAvail )
 import RnSource                ( rnSourceDecls, rnTyClDecl, rnIfaceRuleDecl, rnInstDecl )
-import RnIfaces                ( slurpImpDecls, mkImportInfo, 
+import RnIfaces                ( slurpImpDecls, mkImportInfo, recordLocalSlurps,
                          getInterfaceExports, closeDecls,
                          RecompileRequired, outOfDate, recompileRequired
                        )
@@ -101,7 +101,7 @@ renameExpr :: DynFlags
           -> HomeIfaceTable -> HomeSymbolTable
           -> PersistentCompilerState 
           -> Module -> RdrNameHsExpr
-          -> IO (PersistentCompilerState, Maybe (PrintUnqualified, RenamedHsExpr))
+          -> IO (PersistentCompilerState, Maybe (PrintUnqualified, (RenamedHsExpr, [RenamedHsDecl])))
 
 renameExpr dflags hit hst pcs this_module expr
   | Just iface <- lookupModuleEnv hit this_module
@@ -109,13 +109,11 @@ renameExpr dflags hit hst pcs this_module expr
        ; let print_unqual = unQualInScope rdr_env
          
        ; renameSource dflags hit hst pcs this_module $
-         initRnMS rdr_env emptyLocalFixityEnv SourceMode $
-         ( rnExpr expr `thenRn` \ (e,_) -> 
-
-           doptRn Opt_D_dump_rn `thenRn` \ dump_rn ->
-           ioToRnM (dumpIfSet dump_rn "Renamer:" (ppr e)) `thenRn_`
-
-           returnRn (Just (print_unqual, e)))
+         initRnMS rdr_env emptyLocalFixityEnv SourceMode (rnExpr expr) `thenRn` \ (e,fvs) -> 
+         closeDecls [] fvs                                             `thenRn` \ decls ->
+         doptRn Opt_D_dump_rn                                          `thenRn` \ dump_rn ->
+         ioToRnM (dumpIfSet dump_rn "Renamer:" (ppr e))                `thenRn_`
+         returnRn (Just (print_unqual, (e, decls)))
        }
 
   | otherwise
@@ -565,7 +563,10 @@ closeIfaceDecls dflags hit hst pcs
        needed = unionManyNameSets (map ruleDeclFVs rule_decls) `unionNameSets`
                 unionManyNameSets (map instDeclFVs inst_decls) `unionNameSets`
                 unionManyNameSets (map tyClDeclFVs tycl_decls)
+       local_names    = foldl add emptyNameSet tycl_decls
+       add names decl = addListToNameSet names (map fst (tyClDeclSysNames decl ++ tyClDeclNames decl))
     in
+    recordLocalSlurps local_names      `thenRn_`
     closeDecls decls needed
 \end{code}