summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 07:46:50 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 07:46:50 +0100
commit3bf0520aea5acbecb83dcc0fc722c79ce9f5723c (patch)
treebb641aecf9cf263c1ebc30a11625e5d41991bf6f /compiler
parent7624efc0652cd8393068ed6613df5d1c01d58044 (diff)
downloadhaskell-3bf0520aea5acbecb83dcc0fc722c79ce9f5723c.tar.gz
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.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/iface/IfaceSyn.lhs10
-rw-r--r--compiler/iface/MkIface.lhs24
2 files changed, 29 insertions, 5 deletions
diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs
index 8ca6b392ae..b5da626296 100644
--- a/compiler/iface/IfaceSyn.lhs
+++ b/compiler/iface/IfaceSyn.lhs
@@ -280,7 +280,15 @@ that is what is seen by importing module with --make
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.
+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
diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs
index a72ed4eabd..fcf7c31c08 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