Skip to content

Commit 57cf81e

Browse files
jhrcekpepeiborra
andauthored
Handle re-exported modules when constructing ExportsMap (#2468)
* Handle re-exported modules when constructing ExportsMap * Remove unused import, use let Co-authored-by: Pepe Iborra <[email protected]>
1 parent 3a271a4 commit 57cf81e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

ghcide/src/Development/IDE/Types/HscEnvEq.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Control.Concurrent.Strict (modifyVar, newVar)
1616
import Control.DeepSeq (force)
1717
import Control.Exception (evaluate, mask, throwIO)
1818
import Control.Monad.Extra (eitherM, join, mapMaybeM)
19-
import Control.Monad.IO.Class
2019
import Data.Either (fromRight)
2120
import Data.Set (Set)
2221
import qualified Data.Set as Set
@@ -76,22 +75,25 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do
7675
-- compute the package imports
7776
let pkgst = unitState hscEnv
7877
depends = explicitUnits pkgst
79-
targets =
80-
[ (pkg, mn)
78+
modules =
79+
[ m
8180
| d <- depends
8281
, Just pkg <- [lookupPackageConfig d hscEnv]
83-
, (mn, _) <- unitExposedModules pkg
82+
, (modName, maybeOtherPkgMod) <- unitExposedModules pkg
83+
, let m = case maybeOtherPkgMod of
84+
-- When module is re-exported from another package,
85+
-- the origin module is represented by value in Just
86+
Just otherPkgMod -> otherPkgMod
87+
Nothing -> mkModule (unitInfoId pkg) modName
8488
]
8589

86-
doOne (pkg, mn) = do
87-
modIface <- liftIO $ initIfaceLoad hscEnv $ loadInterface
88-
""
89-
(mkModule (unitInfoId pkg) mn)
90-
(ImportByUser NotBoot)
90+
doOne m = do
91+
modIface <- initIfaceLoad hscEnv $
92+
loadInterface "" m (ImportByUser NotBoot)
9193
return $ case modIface of
9294
Maybes.Failed _r -> Nothing
9395
Maybes.Succeeded mi -> Just mi
94-
modIfaces <- mapMaybeM doOne targets
96+
modIfaces <- mapMaybeM doOne modules
9597
return $ createExportsMap modIfaces
9698

9799
-- similar to envPackageExports, evaluated lazily

0 commit comments

Comments
 (0)