Note [Resolving never-exported Names]
For the high-level overview, see Note [Handling never-exported TyThings under Backpack] As described in 'typecheckIfacesForMerging', the splendid innovation of signature merging is to rewrite all Names in each of the signatures we are merging together to a pre-merged structure; this is the key ingredient that lets us solve some problems when merging type synonyms. However, when a 'Name' refers to a NON-exported entity, as is the case with the DFun of a ClsInst, or a CoAxiom of a type family, this strategy causes problems: if we pick one and rewrite all references to a shared 'Name', we will accidentally fail to check if the DFun or CoAxioms are compatible, as they will never be checked--only exported entities are checked for compatibility, and a non-exported TyThing is checked WHEN we are checking the ClsInst or type family for compatibility in checkBootDeclM. By virtue of the fact that everything's been pointed to the merged declaration, you'll never notice there's a difference even if there is one. Fortunately, there are only a few places in the interface declarations where this can occur, so we replace those calls with 'tcIfaceImplicit', which will consult a local TypeEnv that records any never-exported TyThings which we should wire up with. Note that we actually knot-tie this local TypeEnv (the 'fixM'), because a type family can refer to a coercion axiom, all of which are done in one go when we typecheck 'mi_decls'. An alternate strategy would be to typecheck coercions first before type families, but that seemed more fragile.
References 1
- Handling never-exported TyThings under Backpack GHC.Tc.Utils.Backpack
Referenced by 5
- GHC.IfaceToCore call site ×3
- GHC.Tc.Types call site
- Handling never-exported TyThings under Backpack GHC.Tc.Utils.Backpack