Skip to content

Commit

Permalink
Handle re-exported modules when constructing ExportsMap
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrcek committed Dec 11, 2021
1 parent f128085 commit 0efbabb
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ghcide/src/Development/IDE/Types/HscEnvEq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,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
, m <- pure $ 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

0 comments on commit 0efbabb

Please sign in to comment.