Skip to content

Commit 08624ea

Browse files
authored
Merge branch 'master' into wip/multi-comp-fixes
2 parents 281ffad + c9519af commit 08624ea

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module Development.IDE.Core.Compile
3636
, TypecheckHelpers(..)
3737
, sourceTypecheck
3838
, sourceParser
39+
, shareUsages
3940
) where
4041

4142
import Control.Monad.IO.Class
@@ -472,6 +473,8 @@ filterUsages = id
472473
#endif
473474

474475
-- | Mitigation for https://gitlab.haskell.org/ghc/ghc/-/issues/22744
476+
-- Important to do this immediately after reading the unit before
477+
-- anything else has a chance to read `mi_usages`
475478
shareUsages :: ModIface -> ModIface
476479
shareUsages iface = iface {mi_usages = usages}
477480
where usages = map go (mi_usages iface)
@@ -1490,11 +1493,28 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
14901493
| source_version <= dest_version -> SourceUnmodified
14911494
| otherwise -> SourceModified
14921495

1496+
old_iface <- case mb_old_iface of
1497+
Just iface -> pure (Just iface)
1498+
Nothing -> do
1499+
let ncu = hsc_NC sessionWithMsDynFlags
1500+
read_dflags = hsc_dflags sessionWithMsDynFlags
1501+
#if MIN_VERSION_ghc(9,3,0)
1502+
read_result <- liftIO $ readIface read_dflags ncu mod iface_file
1503+
#else
1504+
read_result <- liftIO $ initIfaceCheck (text "readIface") sessionWithMsDynFlags
1505+
$ readIface mod iface_file
1506+
#endif
1507+
case read_result of
1508+
Util.Failed{} -> return Nothing
1509+
-- important to call `shareUsages` here before checkOldIface
1510+
-- consults `mi_usages`
1511+
Util.Succeeded iface -> return $ Just (shareUsages iface)
1512+
14931513
-- If mb_old_iface is nothing then checkOldIface will load it for us
14941514
-- given that the source is unmodified
14951515
(recomp_iface_reqd, mb_checked_iface)
14961516
#if MIN_VERSION_ghc(9,3,0)
1497-
<- liftIO $ checkOldIface sessionWithMsDynFlags ms mb_old_iface >>= \case
1517+
<- liftIO $ checkOldIface sessionWithMsDynFlags ms old_iface >>= \case
14981518
UpToDateItem x -> pure (UpToDate, Just x)
14991519
OutOfDateItem reason x -> pure (NeedsRecompile reason, x)
15001520
#else
@@ -1508,8 +1528,7 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
15081528
regenerate linkableNeeded
15091529

15101530
case (mb_checked_iface, recomp_iface_reqd) of
1511-
(Just iface', UpToDate) -> do
1512-
let iface = shareUsages iface'
1531+
(Just iface, UpToDate) -> do
15131532
details <- liftIO $ mkDetailsFromIface sessionWithMsDynFlags iface
15141533
-- parse the runtime dependencies from the annotations
15151534
let runtime_deps

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module Development.IDE.GHC.Compat.Core (
3939
lookupType,
4040
needWiredInHomeIface,
4141
loadWiredInHomeIface,
42+
readIface,
4243
loadSysInterface,
4344
importDecl,
4445
#if MIN_VERSION_ghc(8,8,0)

0 commit comments

Comments
 (0)