Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle re-exported modules when constructing ExportsMap #2468

Merged
merged 4 commits into from
Dec 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions ghcide/src/Development/IDE/Types/HscEnvEq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Control.Concurrent.Strict (modifyVar, newVar)
import Control.DeepSeq (force)
import Control.Exception (evaluate, mask, throwIO)
import Control.Monad.Extra (eitherM, join, mapMaybeM)
import Control.Monad.IO.Class
import Data.Either (fromRight)
import Data.Set (Set)
import qualified Data.Set as Set
Expand Down Expand Up @@ -76,22 +75,25 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do
-- compute the package imports
let pkgst = unitState hscEnv
depends = explicitUnits pkgst
targets =
[ (pkg, mn)
modules =
[ m
| d <- depends
, Just pkg <- [lookupPackageConfig d hscEnv]
, (mn, _) <- unitExposedModules pkg
, (modName, maybeOtherPkgMod) <- unitExposedModules pkg
, let m = case maybeOtherPkgMod of
-- When module is re-exported from another package,
-- the origin module is represented by value in Just
Just otherPkgMod -> otherPkgMod
Nothing -> mkModule (unitInfoId pkg) modName
]

doOne (pkg, mn) = do
modIface <- liftIO $ initIfaceLoad hscEnv $ loadInterface
""
(mkModule (unitInfoId pkg) mn)
(ImportByUser NotBoot)
doOne m = do
modIface <- initIfaceLoad hscEnv $
loadInterface "" m (ImportByUser NotBoot)
return $ case modIface of
Maybes.Failed _r -> Nothing
Maybes.Succeeded mi -> Just mi
modIfaces <- mapMaybeM doOne targets
modIfaces <- mapMaybeM doOne modules
return $ createExportsMap modIfaces

-- similar to envPackageExports, evaluated lazily
Expand Down