Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ghcide-test/data/boot-linkable/Clash/Promoted/Nat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Clash.Promoted.Nat (SNat) where

import Clash.XException ()

data SNat = SNat
7 changes: 7 additions & 0 deletions ghcide-test/data/boot-linkable/Clash/Promoted/Nat/Literals.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{-# LANGUAGE TemplateHaskell #-}

module Clash.Promoted.Nat.Literals where

import Clash.Promoted.Nat.TH

$(snatSplice)
8 changes: 8 additions & 0 deletions ghcide-test/data/boot-linkable/Clash/Promoted/Nat/TH.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE TemplateHaskell #-}
module Clash.Promoted.Nat.TH (snatSplice) where

import Language.Haskell.TH (Q, Dec)
import Clash.Promoted.Nat ()

snatSplice :: Q [Dec]
snatSplice = pure []
3 changes: 3 additions & 0 deletions ghcide-test/data/boot-linkable/Clash/XException.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Clash.XException () where

import Clash.XException.Internal ()
1 change: 1 addition & 0 deletions ghcide-test/data/boot-linkable/Clash/XException.hs-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Clash.XException where
3 changes: 3 additions & 0 deletions ghcide-test/data/boot-linkable/Clash/XException/Internal.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Clash.XException.Internal where

import {-# SOURCE #-} Clash.XException ()
8 changes: 8 additions & 0 deletions ghcide-test/data/boot-linkable/hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cradle:
direct:
arguments:
- "Clash.XException"
- "Clash.XException.Internal"
- "Clash.Promoted.Nat"
- "Clash.Promoted.Nat.Literals"
- "Clash.Promoted.Nat.TH"
4 changes: 4 additions & 0 deletions ghcide-test/exe/BootTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ tests = testGroup "boot"
, testCase "graph with boot modules" $ runWithExtraFiles "boot2" $ \dir -> do
_ <- openDoc (dir </> "A.hs") "haskell"
expectNoMoreDiagnostics 2
, testCase "GetLinkable on hs-boot via TH splice (clash-compiler reproducer)" $
runWithExtraFiles "boot-linkable" $ \dir -> do
_ <- openDoc (dir </> "Clash" </> "Promoted" </> "Nat.hs") "haskell"
expectNoMoreDiagnostics 10
]
21 changes: 19 additions & 2 deletions ghcide/src/Development/IDE/Import/DependencyInformation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ import Development.IDE.GHC.Compat
import Development.IDE.GHC.Compat.Util (Fingerprint)
import qualified Development.IDE.GHC.Compat.Util as Util
import Development.IDE.GHC.Orphans ()
import Development.IDE.Import.FindImports (ArtifactsLocation (..))
import Development.IDE.Import.FindImports (ArtifactsLocation (..),
isBootLocation)
import Development.IDE.Types.Diagnostics
import Development.IDE.Types.Location
import GHC.Generics (Generic)
Expand Down Expand Up @@ -273,7 +274,23 @@ processDependencyInformation RawDependencyInformation{..} rawBootMap mg shallowF
foldr (\(p, cs) res ->
let new = IntMap.fromList (map (, IntSet.singleton (coerce p)) (coerce cs))
in IntMap.unionWith IntSet.union new res ) IntMap.empty successEdges
reverseModuleMap = mkModuleEnv $ map (\(i,sm) -> (showableModule sm, FilePathId i)) $ IntMap.toList rawModuleMap
-- Map 'Module' to 'FilePathId'. A 'Module' does not distinguish boot
-- from non-boot, so a real source file and its hs-boot share the same
-- key. We list boot entries first and non-boot entries second so that
-- 'mkModuleEnv' (right-biased on duplicates) makes the non-boot entry
-- win when both exist: callers like the 'GetLinkable' rule (via
-- 'lookupModuleFile') need the non-boot file because hs-boot files
-- don't have linkables. Boot-only modules still resolve to the boot
-- file, which is required for the home-unit finder cache used during
-- compilation of SOURCE imports.
(bootEntries, srcEntries) = partitionEithers
[ if isBootLocation al
then Left (showableModule sm, FilePathId i)
else Right (showableModule sm, FilePathId i)
| (i, sm) <- IntMap.toList rawModuleMap
, Just al <- [IntMap.lookup i (idToPathMap rawPathIdMap)]
]
reverseModuleMap = mkModuleEnv (bootEntries ++ srcEntries)


-- | Given a dependency graph, buildResultGraph detects and propagates errors in that graph as follows:
Expand Down
3 changes: 2 additions & 1 deletion ghcide/src/Development/IDE/Import/FindImports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ data Import
data ArtifactsLocation = ArtifactsLocation
{ artifactFilePath :: !NormalizedFilePath
, artifactModLocation :: !(Maybe ModLocation)
, artifactIsSource :: !Bool -- ^ True if a module is a source input
, artifactIsSource :: !Bool -- ^ 'True' for a real Haskell source file ('HsSrcFile');
-- 'False' for a boot ('HsBootFile') or signature ('HsigFile') file.
, artifactModule :: !(Maybe Module)
} deriving Show

Expand Down
Loading