@@ -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,23 @@ 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 when both exist: callers like the 'GetLinkable' rule (via
282+ -- 'lookupModuleFile') need the non-boot file because hs-boot files
283+ -- don't have linkables. Boot-only modules still resolve to the boot
284+ -- file, which is required for the home-unit finder cache used during
285+ -- compilation of SOURCE imports.
286+ (bootEntries, srcEntries) = partitionEithers
287+ [ if isBootLocation al
288+ then Left (showableModule sm, FilePathId i)
289+ else Right (showableModule sm, FilePathId i)
290+ | (i, sm) <- IntMap. toList rawModuleMap
291+ , Just al <- [IntMap. lookup i (idToPathMap rawPathIdMap)]
292+ ]
293+ reverseModuleMap = mkModuleEnv (bootEntries ++ srcEntries)
277294
278295
279296-- | Given a dependency graph, buildResultGraph detects and propagates errors in that graph as follows:
0 commit comments