Skip to content

Commit 3032c6e

Browse files
committed
Fix regression in GhcSessionDeps
We cannot use GetModIfaceWithoutLinkable since the session might be reused later to load a module that needs linkables Note that this does not have any effects on performance, since GetModIfaceWithoutLinkable is just a synonym for GetModIface that removes the linkable Fixes #2379
1 parent b7e3a64 commit 3032c6e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,11 @@ loadGhcSession ghcSessionDepsConfig = do
688688

689689
data GhcSessionDepsConfig = GhcSessionDepsConfig
690690
{ checkForImportCycles :: Bool
691-
, forceLinkables :: Bool
692691
, fullModSummary :: Bool
693692
}
694693
instance Default GhcSessionDepsConfig where
695694
def = GhcSessionDepsConfig
696695
{ checkForImportCycles = True
697-
, forceLinkables = False
698696
, fullModSummary = False
699697
}
700698

@@ -712,12 +710,7 @@ ghcSessionDepsDefinition GhcSessionDepsConfig{..} env file = do
712710
else uses_ GetModSummaryWithoutTimestamps (file:deps)
713711

714712
depSessions <- map hscEnv <$> uses_ GhcSessionDeps deps
715-
let uses_th_qq =
716-
xopt LangExt.TemplateHaskell dflags || xopt LangExt.QuasiQuotes dflags
717-
dflags = ms_hspp_opts ms
718-
ifaces <- if uses_th_qq || forceLinkables
719-
then uses_ GetModIface deps
720-
else uses_ GetModIfaceWithoutLinkable deps
713+
ifaces <- uses_ GetModIface deps
721714

722715
let inLoadOrder = map hirHomeMod ifaces
723716
session' <- liftIO $ mergeEnvs hsc mss inLoadOrder depSessions

ghcide/test/exe/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,7 @@ thTests =
40184018
_ <- createDoc "B.hs" "haskell" sourceB
40194019
return ()
40204020
, thReloadingTest False
4021+
, thLoadingTest
40214022
, ignoreInWindowsBecause "Broken in windows" $ thReloadingTest True
40224023
-- Regression test for https://github.com/haskell/haskell-language-server/issues/891
40234024
, thLinkingTest False
@@ -4055,6 +4056,14 @@ thTests =
40554056
expectDiagnostics [ ( cPath, [(DsWarning, (3, 0), "Top-level binding with no type signature: a :: A")] ) ]
40564057
]
40574058

4059+
-- | Test that all modules have linkables
4060+
thLoadingTest :: TestTree
4061+
thLoadingTest = testCase "Loading linkables" $ runWithExtraFiles "THLoading" $ \dir -> do
4062+
let thb = dir </> "THB.hs"
4063+
_ <- openDoc thb "haskell"
4064+
expectDiagnostics [ ( thb, [(DsWarning, (4, 0), "Top-level binding with no type signature: a :: ()")] ) ]
4065+
4066+
40584067
-- | test that TH is reevaluated on typecheck
40594068
thReloadingTest :: Bool -> TestTree
40604069
thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,7 @@ runGetSession st nfp = liftIO $ runAction "eval" st $ do
540540
((_, res),_) <- liftIO $ loadSessionFun fp
541541
let env = fromMaybe (error $ "Unknown file: " <> fp) res
542542
ghcSessionDepsConfig = def
543-
{ forceLinkables = True
544-
, checkForImportCycles = False
543+
{ checkForImportCycles = False
545544
, fullModSummary = True
546545
}
547546
res <- fmap hscEnvWithImportPaths <$> ghcSessionDepsDefinition ghcSessionDepsConfig env nfp

0 commit comments

Comments
 (0)