@@ -88,7 +88,27 @@ newHscEnvEqWithImportPaths envImportPaths se hscEnv deps = do
88
88
-- it's very important to delay the package exports computation
89
89
envPackageExports <- onceAsync $ withSpan " Package Exports" $ \ _sp -> do
90
90
-- compute the package imports
91
- modIfaces <- concat . Map. elems <$> loadPackagesWithModIFaces
91
+ let pkgst = unitState hscEnv
92
+ depends = explicitUnits pkgst
93
+ modules =
94
+ [ m
95
+ | d <- depends
96
+ , Just pkg <- [lookupPackageConfig d hscEnv]
97
+ , (modName, maybeOtherPkgMod) <- unitExposedModules pkg
98
+ , let m = case maybeOtherPkgMod of
99
+ -- When module is re-exported from another package,
100
+ -- the origin module is represented by value in Just
101
+ Just otherPkgMod -> otherPkgMod
102
+ Nothing -> mkModule (unitInfoId pkg) modName
103
+ ]
104
+
105
+ doOne m = do
106
+ modIface <- initIfaceLoad hscEnv $
107
+ loadInterface " " m (ImportByUser NotBoot )
108
+ return $ case modIface of
109
+ Maybes. Failed _r -> Nothing
110
+ Maybes. Succeeded mi -> Just mi
111
+ modIfaces <- mapMaybeM doOne modules
92
112
return $ createExportsMap modIfaces
93
113
94
114
let dflags = hsc_dflags hscEnv
@@ -175,14 +195,18 @@ newHscEnvEqWithImportPaths envImportPaths se hscEnv deps = do
175
195
]
176
196
getModulesForPackage :: Package -> [Module ]
177
197
getModulesForPackage (Package package) =
178
- [ m
179
- | (modName, maybeOtherPkgMod) <- unitExposedModules package
180
- , let m = case maybeOtherPkgMod of
181
- -- When module is re-exported from another package,
182
- -- the origin module is represented by value in Just
183
- Just otherPkgMod -> otherPkgMod
184
- Nothing -> mkModule (unitInfoId package) modName
185
- ]
198
+ map makeModule allModules
199
+ where
200
+ allModules :: [(ModuleName , Maybe Module )]
201
+ allModules = unitExposedModules package
202
+ ++ zip (unitHiddenModules package) (repeat Nothing )
203
+ makeModule :: (ModuleName , Maybe Module )
204
+ -> Module
205
+ makeModule (moduleName, Nothing ) =
206
+ mkModule (unitInfoId package) moduleName
207
+ -- When module is re-exported from another package,
208
+ -- the origin module is represented by value in Just
209
+ makeModule (_, Just otherPackageMod) = otherPackageMod
186
210
187
211
newtype Package = Package UnitInfo deriving Eq
188
212
instance Ord Package where
0 commit comments