diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-09-15 13:14:30 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-09-15 13:15:15 -0700 |
commit | b72478f41b85337b84edab8f625d103e197f116c (patch) | |
tree | e0ab347d2885067bdf6a0964304f2e9f3cd9e4a9 | |
parent | 65f887e1a0d864526f6a2609a3afc2c151c25e38 (diff) | |
download | haskell-b72478f41b85337b84edab8f625d103e197f116c.tar.gz |
Don't offer hidden modules for autocomplete.
It was annoying to test GHCi directly, so I added a ghc-api unit test
of the function instead.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
-rw-r--r-- | compiler/main/Packages.lhs | 3 | ||||
-rw-r--r-- | testsuite/.gitignore | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/T9595.hs | 23 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/T9595.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/all.T | 1 |
5 files changed, 29 insertions, 1 deletions
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs index c14c8cf7f8..a6a61e9534 100644 --- a/compiler/main/Packages.lhs +++ b/compiler/main/Packages.lhs @@ -1304,7 +1304,8 @@ lookupModuleWithSuggestions dflags m mb_pn listVisibleModuleNames :: DynFlags -> [ModuleName] listVisibleModuleNames dflags = - Map.keys (moduleToPkgConfAll (pkgState dflags)) + map fst (filter visible (Map.toList (moduleToPkgConfAll (pkgState dflags)))) + where visible (_, ms) = any originVisible (Map.elems ms) -- | Find all the 'PackageConfig' in both the preload packages from 'DynFlags' and corresponding to the list of -- 'PackageConfig's diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 4f8ac870e6..e8b83e8c3c 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -688,6 +688,7 @@ mk/ghcconfig_*_inplace_bin_ghc-stage2.exe.mk /tests/ghc-api/T7478/T7478 /tests/ghc-api/T8628 /tests/ghc-api/T8639_api +/tests/ghc-api/T9595 /tests/ghc-api/apirecomp001/myghc /tests/ghc-api/dynCompileExpr/dynCompileExpr /tests/ghc-api/ghcApi diff --git a/testsuite/tests/ghc-api/T9595.hs b/testsuite/tests/ghc-api/T9595.hs new file mode 100644 index 0000000000..b6c336ab9a --- /dev/null +++ b/testsuite/tests/ghc-api/T9595.hs @@ -0,0 +1,23 @@ +module Main where + +import GHC +import Packages +import GhcMonad +import Outputable +import System.Environment +import DynFlags +import Module + +main = + do [libdir] <- getArgs + _ <- runGhc (Just libdir) $ do + dflags <- getSessionDynFlags + setSessionDynFlags dflags + dflags <- getSessionDynFlags + liftIO $ print (mkModuleName "Outputable" `elem` listVisibleModuleNames dflags) + _ <- runGhc (Just libdir) $ do + dflags <- getSessionDynFlags + setSessionDynFlags (dflags { packageFlags = [ExposePackage (PackageArg "ghc") Nothing]}) + dflags <- getSessionDynFlags + liftIO $ print (mkModuleName "Outputable" `elem` listVisibleModuleNames dflags) + return () diff --git a/testsuite/tests/ghc-api/T9595.stdout b/testsuite/tests/ghc-api/T9595.stdout new file mode 100644 index 0000000000..91d6f80f27 --- /dev/null +++ b/testsuite/tests/ghc-api/T9595.stdout @@ -0,0 +1,2 @@ +False +True diff --git a/testsuite/tests/ghc-api/all.T b/testsuite/tests/ghc-api/all.T index 489b3edf4d..11e8c422b6 100644 --- a/testsuite/tests/ghc-api/all.T +++ b/testsuite/tests/ghc-api/all.T @@ -8,3 +8,4 @@ test('T8639_api', normal, test('T8628', normal, run_command, ['$MAKE -s --no-print-directory T8628']) +test('T9595', extra_run_opts('"' + config.libdir + '"'), compile_and_run, ['-package ghc']) |