Location information of instances is lost if there is aleady a '.hi' #921
Description
If there is already a '.hi' file present for a module we are haddock-ing, none of the instances in that module will have any location information.
I initially pointed this out in #906 (comment). I'm making a full blown issue for this because it is turning out to be a bit nastier than I expected.
The third field of DocInstance
(the Located (IdP name)
) is where we have a disappearing location:
haddock/haddock-api/src/Haddock/Types.hs
Line 392 in 133e9c2
This is supposed to glean its location off of dfun_id
(or co_ax_name
for type families, although that path is not well documented). There is a Note [Haddock assumptions]
referenced from that field:
Note [Haddock assumptions]
~~~~~~~~~~~~~~~~~~~~~~~~~~
For normal user-written instances, Haddock relies on
* the SrcSpan of
* the Name of
* the is_dfun of
* an Instance
being equal to
* the SrcSpan of
* the instance head type of
* the InstDecl used to construct the Instance.
However, when serializing Name
s in interface files, GHC discards all locations. When reading the interface back out, the location holes get filled with noSrcSpan
. All that to say that this note no longer holds if the class instance was read from an interface file.