@@ -55,10 +55,11 @@ import GHC hiding (verbosity)
55
55
import GHC.Data.Graph.Directed
56
56
import GHC.Driver.Session hiding (verbosity )
57
57
import GHC.Driver.Types (isBootSummary )
58
- import GHC.Driver.Monad (Session ( .. ), modifySession , reflectGhc )
58
+ import GHC.Driver.Monad (modifySession )
59
59
import GHC.Data.FastString (unpackFS )
60
- import GHC.Tc.Types (TcGblEnv (.. ))
61
- import GHC.Tc.Utils.Monad (getTopEnv )
60
+ import GHC.Tc.Types (TcM , TcGblEnv (.. ))
61
+ import GHC.Tc.Utils.Monad (setGblEnv )
62
+ import GHC.Tc.Utils.Env (tcLookupGlobal )
62
63
import GHC.Types.Name (nameIsFromExternalPackage , nameOccName )
63
64
import GHC.Types.Name.Occurrence (isTcOcc )
64
65
import GHC.Types.Name.Reader (unQualOK , gre_name , globalRdrEnvElts )
@@ -200,7 +201,7 @@ plugin verbosity flags instIfaceMap = liftIO $ do
200
201
moduleSetRef <- newIORef emptyModuleSet
201
202
202
203
let
203
- processTypeCheckedResult :: ModSummary -> TcGblEnv -> Ghc ()
204
+ processTypeCheckedResult :: ModSummary -> TcGblEnv -> TcM ()
204
205
processTypeCheckedResult mod_summary tc_gbl_env
205
206
-- Don't do anything for hs-boot modules
206
207
| IsBoot <- isBootSummary mod_summary =
@@ -225,11 +226,8 @@ plugin verbosity flags instIfaceMap = liftIO $ do
225
226
paPlugin = defaultPlugin
226
227
{
227
228
renamedResultAction = keepRenamedSource
228
- , typeCheckResultAction = \ _ mod_summary tc_gbl_env -> do
229
- session <- getTopEnv >>= liftIO . newIORef
230
- liftIO $ reflectGhc
231
- (processTypeCheckedResult mod_summary tc_gbl_env)
232
- (Session session)
229
+ , typeCheckResultAction = \ _ mod_summary tc_gbl_env -> setGblEnv tc_gbl_env $ do
230
+ processTypeCheckedResult mod_summary tc_gbl_env
233
231
pure tc_gbl_env
234
232
235
233
}
@@ -244,31 +242,28 @@ plugin verbosity flags instIfaceMap = liftIO $ do
244
242
)
245
243
246
244
247
-
248
245
processModule1
249
246
:: Verbosity
250
247
-> [Flag ]
251
248
-> IfaceMap
252
249
-> InstIfaceMap
253
250
-> ModSummary
254
251
-> TcGblEnv
255
- -> Ghc (Interface , ModuleSet )
252
+ -> TcM (Interface , ModuleSet )
256
253
processModule1 verbosity flags ifaces inst_ifaces mod_summary tc_gbl_env = do
257
254
out verbosity verbose " Creating interface..."
258
255
259
256
let
260
257
TcGblEnv { tcg_rdr_env } = tc_gbl_env
261
258
262
259
(! interface, messages) <- {-# SCC createInterface #-}
263
- withTimingD " createInterface" (const () ) $
264
- runWriterGhc $ createInterface1 flags mod_summary
265
- tc_gbl_env ifaces inst_ifaces
260
+ withTimingD " createInterface" (const () ) $ runIfM (fmap Just . tcLookupGlobal) $
261
+ createInterface1 flags mod_summary tc_gbl_env ifaces inst_ifaces
266
262
267
263
-- We need to keep track of which modules were somehow in scope so that when
268
264
-- Haddock later looks for instances, it also looks in these modules too.
269
265
--
270
266
-- See https://github.com/haskell/haddock/issues/469.
271
-
272
267
dflags <- getDynFlags
273
268
let
274
269
mods :: ModuleSet
0 commit comments