[project @ 2002-02-06 12:12:25 by keithw]
authorkeithw <unknown>
Wed, 6 Feb 2002 12:12:26 +0000 (12:12 +0000)
committerkeithw <unknown>
Wed, 6 Feb 2002 12:12:26 +0000 (12:12 +0000)
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.

ghc/compiler/rename/RnHsSyn.lhs
ghc/compiler/rename/RnSource.lhs

index 7a955f1..58a1acc 100644 (file)
@@ -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})
index b02f49b..85c7cb5 100644 (file)
@@ -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}