@@ -16,7 +16,6 @@ import Control.Concurrent.Strict (modifyVar, newVar)
1616import Control.DeepSeq (force )
1717import Control.Exception (evaluate , mask , throwIO )
1818import Control.Monad.Extra (eitherM , join , mapMaybeM )
19- import Control.Monad.IO.Class
2019import Data.Either (fromRight )
2120import Data.Set (Set )
2221import 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