Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Populate ms_hs_date in GetModSummary rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Jul 13, 2020
1 parent cbafcf2 commit 42936ba
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ import System.IO.Extra
import Control.DeepSeq (rnf)
import Control.Exception (evaluate)
import Exception (ExceptionMonad)
import Data.Time (getCurrentTime)
import System.IO.Error (isDoesNotExistError)
import TcEnv (tcLookup)


Expand Down Expand Up @@ -451,6 +453,10 @@ getModSummaryFromImports
-> Maybe SB.StringBuffer
-> ExceptT [FileDiagnostic] m ModSummary
getModSummaryFromImports fp contents = do
fileModTime <- liftIO $ getModificationTime fp `catch` \e ->
if isDoesNotExistError e
then getCurrentTime -- Virtual file case
else throwIO e
(contents, dflags) <- preprocessor fp contents
(srcImports, textualImports, L _ moduleName) <-
ExceptT $ liftIO $ first (diagFromErrMsgs "parser" dflags) <$> GHC.getHeaderImports dflags contents fp fp
Expand All @@ -469,10 +475,7 @@ getModSummaryFromImports fp contents = do
#if MIN_GHC_API_VERSION(8,8,0)
, ms_hie_date = Nothing
#endif
, ms_hs_date = error "Rules should not depend on ms_hs_date"
-- When we are working with a virtual file we do not have a file date.
-- To avoid silent issues where something is not processed because the date
-- has not changed, we make sure that things blow up if they depend on the date.
, ms_hs_date = fileModTime
, ms_hsc_src = sourceType
-- The contents are used by the GetModSummary rule
, ms_hspp_buf = Just contents
Expand Down

0 comments on commit 42936ba

Please sign in to comment.