Skip to content

Commit 5c91b12

Browse files
committed
Revert "Remove extra call to newHscEnvEqWithImportPaths"
This reverts commit 376ada0.
1 parent 376ada0 commit 5c91b12

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ import qualified Data.Text.Encoding as T
100100
import Data.Time (UTCTime (..))
101101
import Data.Tuple.Extra
102102
import Data.Typeable (cast)
103-
import qualified Data.Unique as Unique
104103
import Development.IDE.Core.Compile
105104
import Development.IDE.Core.FileExists hiding (LogShake, Log)
106105
import Development.IDE.Core.FileStore (getFileContents,
@@ -772,13 +771,35 @@ ghcSessionDepsDefinition
772771
Bool ->
773772
GhcSessionDepsConfig -> HscEnvEq -> NormalizedFilePath -> Action (Maybe HscEnvEq)
774773
ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
774+
let hsc = hscEnv env
775+
775776
mbdeps <- mapM(fmap artifactFilePath . snd) <$> use_ GetLocatedImports file
776777
case mbdeps of
777778
Nothing -> return Nothing
778779
Just deps -> do
779780
when checkForImportCycles $ void $ uses_ ReportImportCycles deps
780-
let updateUnique newUnique = env { envUnique = newUnique }
781-
Just . updateUnique <$> liftIO Unique.newUnique
781+
ms <- msrModSummary <$> if fullModSummary
782+
then use_ GetModSummary file
783+
else use_ GetModSummaryWithoutTimestamps file
784+
785+
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
786+
ifaces <- uses_ GetModIface deps
787+
let inLoadOrder = map (\HiFileResult{..} -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
788+
#if MIN_VERSION_ghc(9,3,0)
789+
-- On GHC 9.4+, the module graph contains not only ModSummary's but each `ModuleNode` in the graph
790+
-- also points to all the direct descendants of the current module. To get the keys for the descendants
791+
-- we must get their `ModSummary`s
792+
!final_deps <- do
793+
dep_mss <- map msrModSummary <$> uses_ GetModSummaryWithoutTimestamps deps
794+
-- Don't want to retain references to the entire ModSummary when just the key will do
795+
return $!! map (NodeKey_Module . msKey) dep_mss
796+
let moduleNode = (ms, final_deps)
797+
#else
798+
let moduleNode = ms
799+
#endif
800+
session' <- liftIO $ mergeEnvs hsc moduleNode inLoadOrder depSessions
801+
802+
Just <$> liftIO (newHscEnvEqWithImportPaths (envImportPaths env) session' [])
782803

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

ghcide/src/Development/IDE/Types/HscEnvEq.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Development.IDE.Types.HscEnvEq
2-
( HscEnvEq(envUnique),
2+
( HscEnvEq,
33
hscEnv, newHscEnvEq,
44
hscEnvWithImportPaths,
55
newHscEnvEqPreserveImportPaths,

0 commit comments

Comments
 (0)