From 14e92de47ef199abfc1fd84c97cb2b275b0e3f21 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 19 Dec 2000 17:42:13 +0000 Subject: [PATCH] [project @ 2000-12-19 17:42:13 by simonpj] Fix the tcAddImportedIdInfo problem --- ghc/compiler/rename/RnHsSyn.lhs | 17 ++++++++++++++--- ghc/compiler/rename/RnSource.lhs | 8 -------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ghc/compiler/rename/RnHsSyn.lhs b/ghc/compiler/rename/RnHsSyn.lhs index 3ad4a05..3137382 100644 --- a/ghc/compiler/rename/RnHsSyn.lhs +++ b/ghc/compiler/rename/RnHsSyn.lhs @@ -10,7 +10,7 @@ module RnHsSyn where import HsSyn import HsCore -import Class ( FunDep ) +import Class ( FunDep, DefMeth(..) ) import TysWiredIn ( tupleTyCon, listTyCon, charTyCon ) import Name ( Name, getName, isTyVarName ) import NameSet @@ -132,11 +132,22 @@ tyClDeclFVs (TyData {tcdCtxt = context, tcdTyVars = tyvars, tcdCons = condecls, tyClDeclFVs (TySynonym {tcdTyVars = tyvars, tcdSynRhs = ty}) = delFVs (map hsTyVarName tyvars) (extractHsTyNames ty) -tyClDeclFVs (ClassDecl {tcdCtxt = context, tcdTyVars = tyvars, tcdFDs = fds, tcdSigs = sigs}) +tyClDeclFVs (ClassDecl {tcdCtxt = context, tcdTyVars = tyvars, tcdFDs = fds, + tcdSigs = sigs, tcdMeths = maybe_meths}) = delFVs (map hsTyVarName tyvars) $ extractHsCtxtTyNames context `plusFV` plusFVs (map extractFunDepNames fds) `plusFV` - hsSigsFVs sigs + hsSigsFVs sigs `plusFV` + dm_fvs + where + dm_fvs = case maybe_meths of + Nothing -> mkFVs [v | ClassOpSig _ (DefMeth v) _ _ <- sigs] + -- No method bindings, so this class decl comes from an interface file, + -- So we want to treat the default-method names as free (they should + -- be defined somewhere else). [In source code this is not so; the class + -- decl will bind whatever default-methods are necessary.] + Just _ -> emptyFVs -- Source code, so the default methods + -- are *bound* not *free* ---------------- hsSigsFVs sigs = plusFVs (map hsSigFVs sigs) diff --git a/ghc/compiler/rename/RnSource.lhs b/ghc/compiler/rename/RnSource.lhs index 31330f6..21e307b 100644 --- a/ghc/compiler/rename/RnSource.lhs +++ b/ghc/compiler/rename/RnSource.lhs @@ -397,14 +397,6 @@ rnClassOp clas clas_tyvars clas_fds sig@(ClassOpSig op dm_stuff ty locn) returnRn (ClassOpSig op_name dm_stuff' new_ty locn) rnClassBinds :: RdrNameTyClDecl -> RenamedTyClDecl -> RnMS (RenamedTyClDecl, FreeVars) -rnClassBinds (ClassDecl {tcdMeths = Nothing}) - rn_cls_decl@(ClassDecl {tcdSigs = sigs}) - -- No method bindings, so this class decl comes from an interface file, - -- However we want to treat the default-method names as free (they should - -- be defined somewhere else). [In source code this is not so; the class - -- decl will bind whatever default-methods are necessary.] - = returnRn (rn_cls_decl, mkFVs [v | ClassOpSig _ (DefMeth v) _ _ <- sigs]) - rnClassBinds (ClassDecl {tcdMeths = Just mbinds}) -- Get mbinds from here rn_cls_decl@(ClassDecl {tcdTyVars = tyvars, tcdLoc = src_loc}) -- Everything else is here -- There are some default-method bindings (abeit possibly empty) so -- 1.7.10.4