Skip to content

Commit 736ba18

Browse files
authored
Fix a bug in getHiFileRule (haskell/ghcide#623)
* Fix bug in getHiFileRule * Renamed GetHiFile to GetModIfaceFromDisk for clarity
1 parent dcce571 commit 736ba18

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Development/IDE/Core/RuleTypes.hs

+8-7
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ type instance RuleResult GetLocatedImports = ([(Located ModuleName, Maybe Artifa
9797
-- we can only report diagnostics for the current file.
9898
type instance RuleResult ReportImportCycles = ()
9999

100-
-- | Read the module interface file
101-
type instance RuleResult GetHiFile = HiFileResult
100+
-- | Read the module interface file from disk. Throws an error for VFS files.
101+
-- This is an internal rule, use 'GetModIface' instead.
102+
type instance RuleResult GetModIfaceFromDisk = HiFileResult
102103

103-
-- | Get a module interface, either from an interface file or a typechecked module
104+
-- | Get a module interface details, either from an interface file or a typechecked module
104105
type instance RuleResult GetModIface = HiFileResult
105106

106107
type instance RuleResult IsFileOfInterest = Bool
@@ -169,11 +170,11 @@ instance Hashable GhcSession
169170
instance NFData GhcSession
170171
instance Binary GhcSession
171172

172-
data GetHiFile = GetHiFile
173+
data GetModIfaceFromDisk = GetModIfaceFromDisk
173174
deriving (Eq, Show, Typeable, Generic)
174-
instance Hashable GetHiFile
175-
instance NFData GetHiFile
176-
instance Binary GetHiFile
175+
instance Hashable GetModIfaceFromDisk
176+
instance NFData GetModIfaceFromDisk
177+
instance Binary GetModIfaceFromDisk
177178

178179
data GetModIface = GetModIface
179180
deriving (Eq, Show, Typeable, Generic)

src/Development/IDE/Core/Rules.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,11 @@ loadGhcSession = do
588588
Nothing -> BS.pack (show (hash (snd val)))
589589
return (Just cutoffHash, val)
590590

591-
getHiFileRule :: Rules ()
592-
getHiFileRule = defineEarlyCutoff $ \GetHiFile f -> do
591+
getModIfaceFromDiskRule :: Rules ()
592+
getModIfaceFromDiskRule = defineEarlyCutoff $ \GetModIfaceFromDisk f -> do
593593
-- get all dependencies interface files, to check for freshness
594594
(deps,_) <- use_ GetLocatedImports f
595-
depHis <- traverse (use GetHiFile) (mapMaybe (fmap artifactFilePath . snd) deps)
595+
depHis <- traverse (use GetModIface) (mapMaybe (fmap artifactFilePath . snd) deps)
596596

597597
ms <- use_ GetModSummary f
598598
let hiFile = toNormalizedFilePath'
@@ -618,7 +618,7 @@ getHiFileRule = defineEarlyCutoff $ \GetHiFile f -> do
618618
let diag = ideErrorWithSource (Just "interface file loading") (Just DsError) f . T.pack $ err
619619
return (Nothing, (pure diag, Nothing))
620620
(_, VFSVersion{}) ->
621-
error "internal error - GetHiFile of file of interest"
621+
error "internal error - GetModIfaceFromDisk of file of interest"
622622
_ ->
623623
pure (Nothing, ([], Nothing))
624624

@@ -636,7 +636,7 @@ getModIfaceRule = define $ \GetModIface f -> do
636636
let useHiFile =
637637
-- Never load interface files for files of interest
638638
not fileOfInterest
639-
mbHiFile <- if useHiFile then use GetHiFile f else return Nothing
639+
mbHiFile <- if useHiFile then use GetModIfaceFromDisk f else return Nothing
640640
case mbHiFile of
641641
Just x ->
642642
return ([], Just x)
@@ -696,7 +696,7 @@ mainRule = do
696696
generateCoreRule
697697
generateByteCodeRule
698698
loadGhcSession
699-
getHiFileRule
699+
getModIfaceFromDiskRule
700700
getModIfaceRule
701701
isFileOfInterestRule
702702
getModSummaryRule

0 commit comments

Comments
 (0)