@@ -53,7 +53,8 @@ import Development.IDE.GHC.Compat
5353import Development.IDE.GHC.Compat.Util (Fingerprint )
5454import qualified Development.IDE.GHC.Compat.Util as Util
5555import Development.IDE.GHC.Orphans ()
56- import Development.IDE.Import.FindImports (ArtifactsLocation (.. ))
56+ import Development.IDE.Import.FindImports (ArtifactsLocation (.. ),
57+ isBootLocation )
5758import Development.IDE.Types.Diagnostics
5859import Development.IDE.Types.Location
5960import GHC.Generics (Generic )
@@ -273,7 +274,25 @@ processDependencyInformation RawDependencyInformation{..} rawBootMap mg shallowF
273274 foldr (\ (p, cs) res ->
274275 let new = IntMap. fromList (map (, IntSet. singleton (coerce p)) (coerce cs))
275276 in IntMap. unionWith IntSet. union new res ) IntMap. empty successEdges
276- reverseModuleMap = mkModuleEnv $ map (\ (i,sm) -> (showableModule sm, FilePathId i)) $ IntMap. toList rawModuleMap
277+ -- Map 'Module' to 'FilePathId'. A 'Module' does not distinguish boot
278+ -- from non-boot, so a real source file and its hs-boot share the same
279+ -- key. We list boot entries first and non-boot entries second so that
280+ -- 'mkModuleEnv' (right-biased on duplicates) makes the non-boot entry
281+ -- win: callers like the 'GetLinkable' rule (via 'lookupModuleFile')
282+ -- need the non-boot file because hs-boot files don't have linkables.
283+ --
284+ -- XXX: It's unclear whether this code can be called in a situation
285+ -- where a module ONLY has a boot module. If that situation
286+ -- can't occur, the snippet below can be simplified to simply
287+ -- filter all boot entries.
288+ (bootEntries, srcEntries) = partitionEithers
289+ [ if isBootLocation al
290+ then Left (showableModule sm, FilePathId i)
291+ else Right (showableModule sm, FilePathId i)
292+ | (i, sm) <- IntMap. toList rawModuleMap
293+ , Just al <- [IntMap. lookup i (idToPathMap rawPathIdMap)]
294+ ]
295+ reverseModuleMap = mkModuleEnv (bootEntries ++ srcEntries)
277296
278297
279298-- | Given a dependency graph, buildResultGraph detects and propagates errors in that graph as follows:
0 commit comments