@@ -574,8 +574,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
574
574
let new_cache = newComponentCache recorder optExtensions hieYaml _cfp hscEnv
575
575
all_target_details <- new_cache old_deps new_deps
576
576
577
- let new_envs = take (L. length new_deps) all_target_details
578
- all_targets = concatMap fst all_target_details
577
+ let all_targets = concatMap fst all_target_details
579
578
580
579
let this_flags_map = HM. fromList (concatMap toFlagsMap all_targets)
581
580
@@ -594,8 +593,8 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
594
593
595
594
-- Typecheck all files in the project on startup
596
595
checkProject <- getCheckProject
597
- unless (null new_envs || not checkProject) $ do
598
- cfps' <- liftIO $ filterM (IO. doesFileExist . fromNormalizedFilePath) (concatMap ( concatMap targetLocations) $ fmap fst new_envs )
596
+ unless (null new_deps || not checkProject) $ do
597
+ cfps' <- liftIO $ filterM (IO. doesFileExist . fromNormalizedFilePath) (concatMap targetLocations all_targets )
599
598
void $ shakeEnqueue extras $ mkDelayedAction " InitialLoad" Debug $ void $ do
600
599
mmt <- uses GetModificationTime cfps'
601
600
let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
@@ -796,24 +795,26 @@ newComponentCache
796
795
-> [ComponentInfo ]
797
796
-> IO [ ([TargetDetails ], (IdeResult HscEnvEq , DependencyInfo ))]
798
797
newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
799
- let cis = old_cis ++ new_cis
800
- let uids = map (\ ci -> (componentUnitId ci, componentDynFlags ci)) cis
801
- pprTraceM " newComponentCache" $ Compat. ppr (map fst uids)
798
+ let cis = Map. union (mkMap new_cis) (mkMap old_cis) -- Left biased so prefer new components over old ones
799
+ mkMap = Map. fromList . map (\ ci -> (componentUnitId ci, ci))
800
+ let dfs = map componentDynFlags $ Map. elems cis
801
+ uids = Map. keys cis
802
+ pprTraceM " newComponentCache" $ Compat. ppr uids
802
803
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
803
- Compat. initUnits ( map snd uids) hsc_env
804
+ Compat. initUnits dfs hsc_env
804
805
805
806
#if MIN_VERSION_ghc(9,3,0)
806
807
let closure_errs = checkHomeUnitsClosed (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv') pkg_deps
807
808
pkg_deps = do
808
- home_unit_id <- map fst uids
809
+ home_unit_id <- uids
809
810
home_unit_env <- maybeToList $ unitEnv_lookup_maybe home_unit_id $ hsc_HUG hscEnv'
810
811
map (home_unit_id,) (map (Compat. toUnitId . fst ) $ explicitUnits $ homeUnitEnv_units home_unit_env)
811
812
812
813
case closure_errs of
813
814
errs@ (_: _) -> do
814
- let rendered = map (ideErrorWithSource (Just " cradle" ) (Just DsError ) cfp . T. pack . Compat. printWithoutUniques . (, hsc_all_home_unit_ids hscEnv', pprHomeUnitGraph $ ue_home_unit_graph $ hsc_unit_env hscEnv', pkg_deps) ) errs
815
+ let rendered = map (ideErrorWithSource (Just " cradle" ) (Just DsError ) cfp . T. pack . Compat. printWithoutUniques) errs
815
816
res = (rendered,Nothing )
816
- dep_info = foldMap componentDependencyInfo (filter isBad cis)
817
+ dep_info = foldMap componentDependencyInfo (filter isBad $ Map. elems cis)
817
818
bad_units = OS. fromList $ concat $ do
818
819
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat. getMessages errs
819
820
DriverHomePackagesNotClosed us <- pure x
@@ -838,7 +839,7 @@ newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
838
839
case res of
839
840
Nothing -> pure ()
840
841
841
- fmap (addSpecial cfp) $ forM cis $ \ ci -> do
842
+ fmap (addSpecial cfp) $ forM ( Map. elems cis) $ \ ci -> do
842
843
let df = componentDynFlags ci
843
844
let newFunc = maybe newHscEnvEqPreserveImportPaths newHscEnvEq cradlePath
844
845
thisEnv <- do
@@ -862,7 +863,7 @@ newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
862
863
-- getOptions is enough to initialize units on GHC <9.2
863
864
pure $ hscSetFlags df hsc_env { hsc_IC = (hsc_IC hsc_env) { ic_dflags = df } }
864
865
#endif
865
- henv <- newFunc thisEnv uids
866
+ henv <- newFunc thisEnv ( zip uids dfs)
866
867
let targetEnv = ([] , Just henv)
867
868
targetDepends = componentDependencyInfo ci
868
869
res = ( targetEnv, targetDepends)
0 commit comments