Skip to content

Commit 3414636

Browse files
committed
fix: update conditional compilation for GHC version checks
1 parent e7dd3de commit 3414636

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ setNameCache nc hsc = hsc { hsc_NC = nc }
790790
-- Moved back to implementation in GHC.
791791
checkHomeUnitsClosed' :: UnitEnv -> OS.Set UnitId -> [DriverMessages]
792792
checkHomeUnitsClosed' ue _ = checkHomeUnitsClosed ue
793-
#elif MIN_VERSION_ghc(9,3,0)
793+
#else
794794
-- This function checks the important property that if both p and q are home units
795795
-- then any dependency of p, which transitively depends on q is also a home unit.
796796
-- GHC had an implementation of this function, but it was horribly inefficient

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

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ mergeEnvs env mg dep_info ms extraMods envs = do
11101110
| HsSrcFile <- mi_hsc_src (hm_iface a) = a
11111111
| otherwise = b
11121112

1113-
#elif MIN_VERSION_ghc(9,3,0)
1113+
#else
11141114
let im = Compat.installedModule (toUnitId $ moduleUnit $ ms_mod ms) (moduleName (ms_mod ms))
11151115
ifr = InstalledFound (ms_location ms) im
11161116
curFinderCache = Compat.extendInstalledModuleEnv Compat.emptyInstalledModuleEnv im ifr
@@ -1144,31 +1144,6 @@ mergeEnvs env mg dep_info ms extraMods envs = do
11441144
fcModules' <- newIORef $! foldl' (plusInstalledModuleEnv combineModuleLocations) cur fcModules
11451145
fcFiles' <- newIORef $! Map.unions fcFiles
11461146
pure $ FinderCache fcModules' fcFiles'
1147-
1148-
#else
1149-
prevFinderCache <- concatFC <$> mapM (readIORef . hsc_FC) envs
1150-
let im = Compat.installedModule (toUnitId $ moduleUnit $ ms_mod ms) (moduleName (ms_mod ms))
1151-
ifr = InstalledFound (ms_location ms) im
1152-
newFinderCache <- newIORef $! Compat.extendInstalledModuleEnv prevFinderCache im ifr
1153-
return $! loadModulesHome extraMods $
1154-
env{
1155-
hsc_HPT = foldMapBy mergeUDFM emptyUDFM hsc_HPT envs,
1156-
hsc_FC = newFinderCache,
1157-
hsc_mod_graph = mg
1158-
}
1159-
1160-
where
1161-
mergeUDFM = plusUDFM_C combineModules
1162-
combineModules a b
1163-
| HsSrcFile <- mi_hsc_src (hm_iface a) = a
1164-
| otherwise = b
1165-
-- required because 'FinderCache':
1166-
-- 1) doesn't have a 'Monoid' instance,
1167-
-- 2) is abstract and doesn't export constructors
1168-
-- To work around this, we coerce to the underlying type
1169-
-- To remove this, I plan to upstream the missing Monoid instance
1170-
concatFC :: [FinderCache] -> FinderCache
1171-
concatFC = unsafeCoerce (mconcat @(Map InstalledModule InstalledFindResult))
11721147
#endif
11731148

11741149
withBootSuffix :: HscSource -> ModLocation -> ModLocation

0 commit comments

Comments
 (0)