@@ -100,7 +100,6 @@ import qualified Data.Text.Encoding as T
100
100
import Data.Time (UTCTime (.. ))
101
101
import Data.Tuple.Extra
102
102
import Data.Typeable (cast )
103
- import qualified Data.Unique as Unique
104
103
import Development.IDE.Core.Compile
105
104
import Development.IDE.Core.FileExists hiding (LogShake , Log )
106
105
import Development.IDE.Core.FileStore (getFileContents ,
@@ -772,13 +771,35 @@ ghcSessionDepsDefinition
772
771
Bool ->
773
772
GhcSessionDepsConfig -> HscEnvEq -> NormalizedFilePath -> Action (Maybe HscEnvEq )
774
773
ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig {.. } env file = do
774
+ let hsc = hscEnv env
775
+
775
776
mbdeps <- mapM (fmap artifactFilePath . snd ) <$> use_ GetLocatedImports file
776
777
case mbdeps of
777
778
Nothing -> return Nothing
778
779
Just deps -> do
779
780
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' [] )
782
803
783
804
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
784
805
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
0 commit comments