Skip to content
Snippets Groups Projects
Commit 08d28274 authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Ian Lynagh
Browse files

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.
parent 879c4fa1
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment