Refactor lookupExactOrOrig & related functions to not use GlobalRdrElt
We should refactor lookupExactOrOrig
and related functions (lookupExactOcc_either
, lookupExternalExactGRE
) to not just work on the level of GlobalRdrElt
. After all, a GlobalRdrElt
is supposed to be something that's in scope in the current module (either because it's defined locally or imported), while exact and original names bypass scoping to directly refer to something.
The thing is, in the case we are dealing with a normal GlobalRdrElt
, we do need the correct scoping information (the gre_lcl
and gre_imp
fields), because e.g. we rely on it for addUsedGRE
for record fields (see disambiguateRecordBinds
). So we can't simply refactor those functions by returning e.g. (Name, GREInfo)
.
I thus propose the following
data ExactOrigOrGRE
= ExactOrOrig !Name GREInfo
| GRE !GlobalRdrElt
and to use this datatype in functions such as lookupExactOrOrig
.
This refactor would ensure there are no other bugs like #23240 (closed).