This repository was archived by the owner on Aug 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ import GHC hiding (verbosity)
58
58
import HscTypes
59
59
import FastString (unpackFS )
60
60
import MonadUtils (liftIO )
61
+ import TcRnTypes (tcg_rdr_env )
62
+ import RdrName (plusGlobalRdrEnv )
61
63
62
64
#if defined(mingw32_HOST_OS)
63
65
import System.IO
@@ -163,6 +165,18 @@ processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -
163
165
processModule verbosity modsum flags modMap instIfaceMap = do
164
166
out verbosity verbose $ " Checking module " ++ moduleString (ms_mod modsum) ++ " ..."
165
167
tm <- loadModule =<< typecheckModule =<< parseModule modsum
168
+
169
+ -- We need to modify the interactive context's environment so that when
170
+ -- Haddock later looks for instances, it also looks in the modules it
171
+ -- encountered while typechecking.
172
+ --
173
+ -- See https://github.com/haskell/haddock/issues/469.
174
+ hsc_env@ HscEnv { hsc_IC = old_IC } <- getSession
175
+ let new_rdr_env = tcg_rdr_env . fst . GHC. tm_internals_ $ tm
176
+ setSession hsc_env{ hsc_IC = old_IC {
177
+ ic_rn_gbl_env = ic_rn_gbl_env old_IC `plusGlobalRdrEnv` new_rdr_env
178
+ } }
179
+
166
180
if not $ isBootSummary modsum then do
167
181
out verbosity verbose " Creating interface..."
168
182
(interface, msg) <- runWriterGhc $ createInterface tm flags modMap instIfaceMap
You can’t perform that action at this time.
0 commit comments