From: keithw Date: Wed, 6 Feb 2002 12:12:26 +0000 (+0000) Subject: [project @ 2002-02-06 12:12:25 by keithw] X-Git-Tag: Approximately_9120_patches~135 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=37a47dd0a3a72f199a03016513758e5ab82ae760;p=ghc-hetmet.git [project @ 2002-02-06 12:12:25 by keithw] Merging the following onto the HEAD: | 1.61.2.1 +2 -4 fptools/ghc/compiler/rename/RnHsSyn.lhs | 1.135.2.1 +10 -0 fptools/ghc/compiler/rename/RnSource.lhs Original comment (keithw): Remove derivings FVs from tyClDeclFVs, because they aren't needed by interface files. Instead, we return these FVs from finishSourceTyClDecl. --- diff --git a/ghc/compiler/rename/RnHsSyn.lhs b/ghc/compiler/rename/RnHsSyn.lhs index 7a955f1..58a1acc 100644 --- a/ghc/compiler/rename/RnHsSyn.lhs +++ b/ghc/compiler/rename/RnHsSyn.lhs @@ -114,6 +114,7 @@ In all cases this is set up for interface-file declarations: - for class decls we ignore the bindings - for instance decls likewise, plus the pragmas - for rule decls, we ignore HsRules + - for data decls, we ignore derivings *** See "THE NAMING STORY" in HsDecls **** @@ -126,12 +127,9 @@ tyClDeclFVs (IfaceSig {tcdType = ty, tcdIdInfo = id_infos}) = extractHsTyNames ty `plusFV` plusFVs (map hsIdInfoFVs id_infos) -tyClDeclFVs (TyData {tcdCtxt = context, tcdTyVars = tyvars, tcdCons = condecls, tcdDerivs = derivings}) +tyClDeclFVs (TyData {tcdCtxt = context, tcdTyVars = tyvars, tcdCons = condecls}) = delFVs (map hsTyVarName tyvars) $ extractHsCtxtTyNames context `plusFV` - (case derivings of - Nothing -> emptyFVs - Just ds -> extractHsCtxtTyNames ds) `plusFV` plusFVs (map conDeclFVs condecls) tyClDeclFVs (TySynonym {tcdTyVars = tyvars, tcdSynRhs = ty}) diff --git a/ghc/compiler/rename/RnSource.lhs b/ghc/compiler/rename/RnSource.lhs index b02f49b..85c7cb5 100644 --- a/ghc/compiler/rename/RnSource.lhs +++ b/ghc/compiler/rename/RnSource.lhs @@ -45,6 +45,7 @@ import SrcLoc ( SrcLoc ) import CmdLineOpts ( DynFlag(..) ) -- Warn of unused for-all'd tyvars import Maybes ( maybeToBool ) +import Maybe ( maybe ) \end{code} @rnSourceDecl@ `renames' declarations. @@ -433,6 +434,15 @@ finishSourceTyClDecl (ClassDecl {tcdMeths = Just mbinds, tcdLoc = src_loc}) -- G where meth_doc = text "In the default-methods for class" <+> ppr (tcdName rn_cls_decl) +finishSourceTyClDecl _ tycl_decl@(TyData {tcdDerivs = derivings}) + -- Derivings are returned here so that they don't form part of the tyClDeclFVs. + -- This is important, because tyClDeclFVs should contain only the + -- FVs that are `needed' by the interface file declaration, and + -- derivings do not appear in this. It also means that the tcGroups + -- are smaller, which turned out to be important for the usage inference. KSW 2002-02. + = returnRn (tycl_decl, + maybe emptyFVs extractHsCtxtTyNames derivings) + finishSourceTyClDecl _ tycl_decl = returnRn (tycl_decl, emptyFVs) -- Not a class declaration \end{code}