Skip to content

Commit 39519d6

Browse files
committed
Use the HscEnv after processing the ModSummary
Makes sure we don't use the initialised plugins. Fixes #4631.
1 parent 59513ff commit 39519d6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -744,18 +744,20 @@ ghcSessionDepsDefinition
744744
:: -- | full mod summary
745745
Bool ->
746746
GhcSessionDepsConfig -> HscEnvEq -> NormalizedFilePath -> Action (Maybe HscEnvEq)
747-
ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
748-
let hsc = hscEnv env
749-
747+
ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} hscEnvEq file = do
750748
mbdeps <- mapM(fmap artifactFilePath . snd) <$> use_ GetLocatedImports file
751749
case mbdeps of
752750
Nothing -> return Nothing
753751
Just deps -> do
754752
when fullModuleGraph $ void $ use_ ReportImportCycles file
755-
ms <- msrModSummary <$> if fullModSummary
753+
msr <- if fullModSummary
756754
then use_ GetModSummary file
757755
else use_ GetModSummaryWithoutTimestamps file
758-
756+
let
757+
ms = msrModSummary msr
758+
-- This `HscEnv` has its plugins initialized in `parsePragmasIntoHscEnv`
759+
-- Fixes the bug in #4631
760+
env = msrHscEnv msr
759761
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
760762
ifaces <- uses_ GetModIface deps
761763
let inLoadOrder = map (\HiFileResult{..} -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
@@ -775,14 +777,14 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
775777
nubOrdOn mkNodeKey (ModuleNode final_deps ms : concatMap mgModSummaries' mgs)
776778
liftIO $ evaluate $ liftRnf rwhnf module_graph_nodes
777779
return $ mkModuleGraph module_graph_nodes
778-
session' <- liftIO $ mergeEnvs hsc mg de ms inLoadOrder depSessions
780+
session' <- liftIO $ mergeEnvs env mg de ms inLoadOrder depSessions
779781

780782
-- Here we avoid a call to to `newHscEnvEqWithImportPaths`, which creates a new
781783
-- ExportsMap when it is called. We only need to create the ExportsMap once per
782784
-- session, while `ghcSessionDepsDefinition` will be called for each file we need
783785
-- to compile. `updateHscEnvEq` will refresh the HscEnv (session') and also
784786
-- generate a new Unique.
785-
Just <$> liftIO (updateHscEnvEq env session')
787+
Just <$> liftIO (updateHscEnvEq hscEnvEq session')
786788

787789
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
788790
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.

0 commit comments

Comments
 (0)