Skip to content

Commit

Permalink
Fix #2693
Browse files Browse the repository at this point in the history
We need to update the package database state in the `HscEnv` after we update
its `DynFlags`. `setSessionDynFlags` handles this for us.
  • Loading branch information
wz1000 committed Mar 14, 2022
1 parent fd34887 commit e649f5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 11 additions & 2 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,17 @@ newComponentCache
-> IO ( [TargetDetails], (IdeResult HscEnvEq, DependencyInfo))
newComponentCache recorder exts cradlePath cfp hsc_env uids ci = do
let df = componentDynFlags ci
let hscEnv' = hscSetFlags df hsc_env
{ hsc_IC = (hsc_IC hsc_env) { ic_dflags = df } }
hscEnv' <-
-- Add the options for the current component to the HscEnv
-- We want to call `setSessionDynFlags` instead of `hscSetFlags`
-- because `setSessionDynFlags` also initializes the package database,
-- which we need for any changes to the package flags in the dynflags
-- to be visible.
-- See #2693
evalGhcEnv hsc_env $ do
_ <- setSessionDynFlags $ df
getSession


let newFunc = maybe newHscEnvEqPreserveImportPaths newHscEnvEq cradlePath
henv <- newFunc hscEnv' uids
Expand Down
5 changes: 2 additions & 3 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5583,8 +5583,7 @@ simpleSubDirectoryTest =
expectNoMoreDiagnostics 0.5

simpleMultiTest :: TestTree
simpleMultiTest = knownBrokenForGhcVersions [GHC92] "#2693" $
testCase "simple-multi-test" $ withLongTimeout $ runWithExtraFiles "multi" $ \dir -> do
simpleMultiTest = testCase "simple-multi-test" $ withLongTimeout $ runWithExtraFiles "multi" $ \dir -> do
let aPath = dir </> "a/A.hs"
bPath = dir </> "b/B.hs"
adoc <- openDoc aPath "haskell"
Expand Down Expand Up @@ -5614,7 +5613,7 @@ simpleMultiTest2 = testCase "simple-multi-test2" $ runWithExtraFiles "multi" $ \

-- Now with 3 components
simpleMultiTest3 :: TestTree
simpleMultiTest3 = knownBrokenForGhcVersions [GHC92] "#2693" $
simpleMultiTest3 =
testCase "simple-multi-test3" $ runWithExtraFiles "multi" $ \dir -> do
let aPath = dir </> "a/A.hs"
bPath = dir </> "b/B.hs"
Expand Down

0 comments on commit e649f5b

Please # to comment.