Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : ghc-7.2
http://hackage.haskell.org/trac/ghc/changeset/08d28274c1d3bcfa5bd04432f7373f29f383e3c7 >--------------------------------------------------------------- commit 08d28274c1d3bcfa5bd04432f7373f29f383e3c7 Author: Simon Peyton Jones <[email protected]> Date: Wed Aug 3 07:46:50 2011 +0100 Include the instances of associated types in the "extras" of a class This fixes Trac #5147, which was going wrong because the class ABI fingerprint wasn't changing when we added or removed a Show instance to the associated type. >--------------------------------------------------------------- compiler/iface/IfaceSyn.lhs | 8 ++++++++ compiler/iface/MkIface.lhs | 24 ++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs index 8ca6b39..b5da626 100644 --- a/compiler/iface/IfaceSyn.lhs +++ b/compiler/iface/IfaceSyn.lhs @@ -282,6 +282,14 @@ Note [Orphans]: the ifInstOrph and ifRuleOrph fields If a module contains any "orphans", then its interface file is read regardless, so that its instances are not missed. + - If an instance is an orphan its ifInstOprh field is Nothing + Otherwise ifInstOrph is (Just n) where n is the Name of a + local class or tycon that witnesses its non-orphan-hood. + This computation is done by MkIface.instanceToIfaceInst + + - Similarly for ifRuleOrph + The computation is done by MkIface.coreRuleToIfaceRule + Roughly speaking, an instance is an orphan if its head (after the =>) mentions nothing defined in this module. Functional dependencies complicate the situation though. Consider diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs index 008b806..45a9055 100644 --- a/compiler/iface/MkIface.lhs +++ b/compiler/iface/MkIface.lhs @@ -650,9 +650,22 @@ type IfaceDeclABI = (Module, IfaceDecl, IfaceDeclExtras) data IfaceDeclExtras = IfaceIdExtras Fixity [IfaceRule] - | IfaceDataExtras Fixity [IfaceInstABI] [(Fixity,[IfaceRule])] - | IfaceClassExtras Fixity [IfaceInstABI] [(Fixity,[IfaceRule])] + + | IfaceDataExtras + Fixity -- Fixity of the tycon itself + [IfaceInstABI] -- Local instances of this tycon + -- See Note [Orphans] in IfaceSyn + [(Fixity,[IfaceRule])] -- For each construcotr, fixity and RULES + + | IfaceClassExtras + Fixity -- Fixity of the class itself + [IfaceInstABI] -- Local instances of this class *or* + -- of its associated data types + -- See Note [Orphans] in IfaceSyn + [(Fixity,[IfaceRule])] -- For each class method, fixity and RULES + | IfaceSynExtras Fixity + | IfaceOtherDeclExtras abiDecl :: IfaceDeclABI -> IfaceDecl @@ -727,9 +740,12 @@ declExtras fix_fn rule_env inst_env decl IfaceDataExtras (fix_fn n) (map ifDFun $ lookupOccEnvL inst_env n) (map (id_extras . ifConOcc) (visibleIfConDecls cons)) - IfaceClass{ifSigs=sigs} -> + IfaceClass{ifSigs=sigs, ifATs=ats} -> IfaceClassExtras (fix_fn n) - (map ifDFun $ lookupOccEnvL inst_env n) + (map ifDFun $ (concatMap (lookupOccEnvL inst_env . ifName) ats) + ++ lookupOccEnvL inst_env n) + -- Include instances of the associated types + -- as well as instances of the class (Trac #5147) [id_extras op | IfaceClassOp op _ _ <- sigs] IfaceSyn{} -> IfaceSynExtras (fix_fn n) _other -> IfaceOtherDeclExtras _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
