summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-05-18 12:01:57 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-13 02:13:03 -0400
commit36e1daf0a604d98a34d9a066a01dd4f5439b4aca (patch)
tree4c1bfcc10867c8e0f8fb0df87df740d527d5ef82
parentbd5810dc4e23331ca4f73ec3b1818c3350b5bbd7 (diff)
downloadhaskell-36e1daf0a604d98a34d9a066a01dd4f5439b4aca.tar.gz
DynFlags: make listVisibleModuleNames take a UnitState
-rw-r--r--compiler/GHC/Unit/State.hs6
-rw-r--r--ghc/GHCi/UI.hs2
-rw-r--r--testsuite/tests/ghc-api/T9595.hs6
3 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
index 2dd0941986..a3a003aeda 100644
--- a/compiler/GHC/Unit/State.hs
+++ b/compiler/GHC/Unit/State.hs
@@ -1997,9 +1997,9 @@ lookupModuleWithSuggestions' pkgs mod_map m mb_pn
(if originVisible origin then SuggestVisible else SuggestHidden)
name mod origin
-listVisibleModuleNames :: DynFlags -> [ModuleName]
-listVisibleModuleNames dflags =
- map fst (filter visible (Map.toList (moduleNameProvidersMap (unitState dflags))))
+listVisibleModuleNames :: UnitState -> [ModuleName]
+listVisibleModuleNames state =
+ map fst (filter visible (Map.toList (moduleNameProvidersMap state)))
where visible (_, ms) = any originVisible (Map.elems ms)
-- | Lookup 'UnitInfo' for every preload unit, for every unit used to
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 568a880154..dc02f68544 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -3516,7 +3516,7 @@ wrapIdentCompleterWithModifier modifChars fun = completeWordWithPrev Nothing wor
-- | Return a list of visible module names for autocompletion.
-- (NB: exposed != visible)
allVisibleModules :: DynFlags -> [ModuleName]
-allVisibleModules dflags = listVisibleModuleNames dflags
+allVisibleModules dflags = listVisibleModuleNames (unitState dflags)
completeExpression = completeQuotedWord (Just '\\') "\"" listFiles
completeIdentifier
diff --git a/testsuite/tests/ghc-api/T9595.hs b/testsuite/tests/ghc-api/T9595.hs
index 3910a20115..468b63a342 100644
--- a/testsuite/tests/ghc-api/T9595.hs
+++ b/testsuite/tests/ghc-api/T9595.hs
@@ -14,7 +14,8 @@ main =
dflags <- getSessionDynFlags
setSessionDynFlags dflags
dflags <- getSessionDynFlags
- liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames dflags)
+ let state = unitState dflags
+ liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames state)
_ <- runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
setSessionDynFlags (dflags {
@@ -23,5 +24,6 @@ main =
(ModRenaming True [])]
})
dflags <- getSessionDynFlags
- liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames dflags)
+ let state = unitState dflags
+ liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames state)
return ()