From 42936ba5644e49361a89ee242f547f7b3e6256ff Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 12 Jul 2020 21:20:52 +0100 Subject: [PATCH] Populate ms_hs_date in GetModSummary rule --- src/Development/IDE/Core/Compile.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Development/IDE/Core/Compile.hs b/src/Development/IDE/Core/Compile.hs index 0856901fb..90d4d92d3 100644 --- a/src/Development/IDE/Core/Compile.hs +++ b/src/Development/IDE/Core/Compile.hs @@ -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) @@ -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 @@ -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