Skip to content

Commit 3988271

Browse files
author
Jaro Reinders
committed
Fix issue with GHC 9.4
1 parent b627909 commit 3988271

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ newComponentCache recorder exts _cfp hsc_env old_cis new_cis = do
881881
ideErrorWithSource
882882
(Just "cradle") (Just DiagnosticSeverity_Warning) _cfp
883883
(T.pack (Compat.printWithoutUniques (singleMessage err)))
884-
#if MIN_VERSION_ghc(9,6,1)
884+
#if MIN_VERSION_ghc(9,5,0)
885885
(Just (fmap GhcDriverMessage err))
886886
#else
887887
Nothing

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ parseHeader dflags filename contents = do
10761076
let loc = mkRealSrcLoc (Util.mkFastString filename) 1 1
10771077
case unP Compat.parseHeader (initParserState (initParserOpts dflags) contents loc) of
10781078
PFailedWithErrorMessages msgs ->
1079-
#if MIN_VERSION_ghc(9,6,1)
1079+
#if MIN_VERSION_ghc(9,5,0)
10801080
throwE $ diagFromErrMsgs sourceParser dflags $ msgs dflags
10811081
#else
10821082
throwE $ diagFromSDocErrMsgs sourceParser dflags $ msgs dflags
@@ -1094,13 +1094,13 @@ parseHeader dflags filename contents = do
10941094
-- errors are those from which a parse tree just can't
10951095
-- be produced.
10961096
unless (null errs) $
1097-
#if MIN_VERSION_ghc(9,6,1)
1097+
#if MIN_VERSION_ghc(9,5,0)
10981098
throwE $ diagFromErrMsgs sourceParser dflags errs
10991099
#else
11001100
throwE $ diagFromSDocErrMsgs sourceParser dflags errs
11011101
#endif
11021102

1103-
#if MIN_VERSION_ghc(9,6,1)
1103+
#if MIN_VERSION_ghc(9,5,0)
11041104
let warnings = diagFromErrMsgs sourceParser dflags warns
11051105
#else
11061106
let warnings = diagFromSDocErrMsgs sourceParser dflags warns
@@ -1122,7 +1122,7 @@ parseFileContents env customPreprocessor filename ms = do
11221122
contents = fromJust $ ms_hspp_buf ms
11231123
case unP Compat.parseModule (initParserState (initParserOpts dflags) contents loc) of
11241124
PFailedWithErrorMessages msgs ->
1125-
#if MIN_VERSION_ghc(9,6,1)
1125+
#if MIN_VERSION_ghc(9,5,0)
11261126
throwE $ diagFromErrMsgs sourceParser dflags $ msgs dflags
11271127
#else
11281128
throwE $ diagFromSDocErrMsgs sourceParser dflags $ msgs dflags
@@ -1160,7 +1160,7 @@ parseFileContents env customPreprocessor filename ms = do
11601160
-- errors are those from which a parse tree just can't
11611161
-- be produced.
11621162
unless (null errors) $
1163-
#if MIN_VERSION_ghc(9,6,1)
1163+
#if MIN_VERSION_ghc(9,5,0)
11641164
throwE $ diagFromErrMsgs sourceParser dflags errors
11651165
#else
11661166
throwE $ diagFromSDocErrMsgs sourceParser dflags errors
@@ -1195,7 +1195,7 @@ parseFileContents env customPreprocessor filename ms = do
11951195
srcs2 <- liftIO $ filterM doesFileExist srcs1
11961196

11971197
let pm = ParsedModule ms parsed' srcs2
1198-
#if MIN_VERSION_ghc(9,6,1)
1198+
#if MIN_VERSION_ghc(9,5,0)
11991199
warnings = diagFromErrMsgs sourceParser dflags warns
12001200
#else
12011201
warnings = diagFromSDocErrMsgs sourceParser dflags warns

ghcide/src/Development/IDE/Core/HaskellErrorIndex.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import qualified Data.Map as M
1010
import qualified Data.Text as T
1111
import Development.IDE.Types.Diagnostics
1212
import GHC.Driver.Errors.Types (GhcMessage)
13-
#if MIN_VERSION_ghc(9,6,1)
13+
#if MIN_VERSION_ghc(9,5,0)
1414
import GHC.Types.Error (diagnosticCode)
1515
#endif
1616
import Ide.Logger (Pretty (..), Priority (..),
@@ -65,7 +65,7 @@ instance FromJSON HaskellErrorIndex where
6565
parseJSON = fmap errorsToIndex <$> parseJSON
6666

6767
initHaskellErrorIndex :: Recorder (WithPriority Log) -> IO (Maybe HaskellErrorIndex)
68-
#if MIN_VERSION_ghc(9,6,1)
68+
#if MIN_VERSION_ghc(9,5,0)
6969
initHaskellErrorIndex recorder = do
7070
res <- tryJust handleJSONError $ tryJust handleHttpError $ httpJSON "https://errors.haskell.org/api/errors.json"
7171
case res of
@@ -86,7 +86,7 @@ initHaskellErrorIndex recorder = pure Nothing
8686
#endif
8787

8888
heiGetError :: HaskellErrorIndex -> GhcMessage -> Maybe HEIError
89-
#if MIN_VERSION_ghc(9,6,1)
89+
#if MIN_VERSION_ghc(9,5,0)
9090
heiGetError (HaskellErrorIndex index) msg
9191
| Just code <- diagnosticCode msg
9292
= showGhcCode code `M.lookup` index

ghcide/src/Development/IDE/GHC/Compat.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,21 @@ corePrepExpr _ = GHC.corePrepExpr
310310

311311
renderMessages :: PsMessages -> (Bag WarnMsg, Bag ErrMsg)
312312
renderMessages msgs =
313-
#if MIN_VERSION_ghc(9,6,1)
313+
#if MIN_VERSION_ghc(9,5,0)
314314
let renderMsgs extractor = (fmap . fmap) GhcPsMessage . getMessages $ extractor msgs
315315
in (renderMsgs psWarnings, renderMsgs psErrors)
316316
#else
317317
let renderMsgs extractor = (fmap . fmap) renderDiagnosticMessageWithHints . getMessages $ extractor msgs
318318
in (renderMsgs psWarnings, renderMsgs psErrors)
319319
#endif
320320

321-
#if MIN_VERSION_ghc(9,6,1)
321+
#if MIN_VERSION_ghc(9,5,0)
322322
pattern PFailedWithErrorMessages :: forall a b. (b -> Bag (MsgEnvelope GhcMessage)) -> ParseResult a
323-
#elif MIN_VERSION_ghc(9,3,0)
323+
#else
324324
pattern PFailedWithErrorMessages :: forall a b. (b -> Bag (MsgEnvelope DecoratedSDoc)) -> ParseResult a
325325
#endif
326326
pattern PFailedWithErrorMessages msgs
327-
#if MIN_VERSION_ghc(9,6,1)
327+
#if MIN_VERSION_ghc(9,5,0)
328328
<- PFailed (const . fmap (fmap GhcPsMessage) . getMessages . getPsErrorMessages -> msgs)
329329
#else
330330
<- PFailed (const . fmap (fmap renderDiagnosticMessageWithHints) . getMessages . getPsErrorMessages -> msgs)

ghcide/src/Development/IDE/GHC/Compat/Driver.hs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,11 @@ import GHC.Utils.Logger
4040
import GHC.Utils.Outputable
4141
import GHC.Utils.Panic.Plain
4242

43-
#if !MIN_VERSION_ghc(9,6,1)
44-
import Development.IDE.GHC.Compat.Core (hscTypecheckRename)
45-
import GHC.Utils.Error (emptyMessages)
46-
#endif
47-
4843
hscTypecheckRenameWithDiagnostics :: HscEnv -> ModSummary -> HsParsedModule
4944
-> IO ((TcGblEnv, RenamedStuff), Messages GhcMessage)
5045
hscTypecheckRenameWithDiagnostics hsc_env mod_summary rdr_module =
51-
#if MIN_VERSION_ghc(9,6,1)
5246
runHsc' hsc_env $ hsc_typecheck True mod_summary (Just rdr_module)
53-
#else
54-
(,emptyMessages) <$> hscTypecheckRename hsc_env mod_summary rdr_module
55-
#endif
5647

57-
#if MIN_VERSION_ghc(9,6,1)
5848
-- ============================================================================
5949
-- DO NOT EDIT - Refer to top of file
6050
-- ============================================================================
@@ -82,7 +72,11 @@ hsc_typecheck keep_rn mod_summary mb_rdr_module = do
8272
Nothing -> hscParse' mod_summary
8373
tc_result0 <- tcRnModule' mod_summary keep_rn' hpm
8474
if hsc_src == HsigFile
75+
#if MIN_VERSION_ghc(9,5,0)
8576
then do (iface, _) <- liftIO $ hscSimpleIface hsc_env Nothing tc_result0 mod_summary
77+
#else
78+
then do (iface, _) <- liftIO $ hscSimpleIface hsc_env tc_result0 mod_summary
79+
#endif
8680
ioMsgMaybe $ hoistTcRnMessage $
8781
tcRnMergeSignatures hsc_env hpm tc_result0 iface
8882
else return tc_result0
@@ -134,11 +128,19 @@ extract_renamed_stuff mod_summary tc_result = do
134128
-- ============================================================================
135129
-- DO NOT EDIT - Refer to top of file
136130
-- ============================================================================
131+
#if MIN_VERSION_ghc(9,5,0)
137132
hscSimpleIface :: HscEnv
138133
-> Maybe CoreProgram
139134
-> TcGblEnv
140135
-> ModSummary
141136
-> IO (ModIface, ModDetails)
142137
hscSimpleIface hsc_env mb_core_program tc_result summary
143138
= runHsc hsc_env $ hscSimpleIface' mb_core_program tc_result summary
144-
#endif
139+
#else
140+
hscSimpleIface :: HscEnv
141+
-> TcGblEnv
142+
-> ModSummary
143+
-> IO (ModIface, ModDetails)
144+
hscSimpleIface hsc_env tc_result summary
145+
= runHsc hsc_env $ hscSimpleIface' tc_result summary
146+
#endif

ghcide/src/Development/IDE/GHC/Compat/Outputable.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pprNoLocMsgEnvelope (MsgEnvelope { errMsgDiagnostic = e
118118

119119

120120

121-
#if MIN_VERSION_ghc(9,6,1)
121+
#if MIN_VERSION_ghc(9,5,0)
122122
type ErrMsg = MsgEnvelope GhcMessage
123123
type WarnMsg = MsgEnvelope GhcMessage
124124
#else

ghcide/src/Development/IDE/Types/Diagnostics.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Development.IDE.Types.Diagnostics (
1919
ideErrorFromLspDiag,
2020
showDiagnostics,
2121
showDiagnosticsColored,
22-
#if MIN_VERSION_ghc(9,6,1)
22+
#if MIN_VERSION_ghc(9,5,0)
2323
showGhcCode,
2424
#endif
2525
IdeResultNoDiagnosticsEarlyCutoff,
@@ -40,7 +40,7 @@ import Development.IDE.GHC.Compat (GhcMessage, MsgEnvelope,
4040
flagSpecName, wWarningFlags)
4141
import Development.IDE.Types.Location
4242
import GHC.Generics
43-
#if MIN_VERSION_ghc(9,6,1)
43+
#if MIN_VERSION_ghc(9,5,0)
4444
import GHC.Types.Error (DiagnosticCode (..),
4545
DiagnosticReason (..),
4646
diagnosticCode,
@@ -99,7 +99,7 @@ ideErrorFromLspDiag lspDiag fdFilePath mbOrigMsg =
9999
FileDiagnostic {..}
100100

101101
setGhcCode :: Maybe (MsgEnvelope GhcMessage) -> LSP.Diagnostic -> LSP.Diagnostic
102-
#if MIN_VERSION_ghc(9,6,1)
102+
#if MIN_VERSION_ghc(9,5,0)
103103
setGhcCode mbOrigMsg diag =
104104
let mbGhcCode = do
105105
origMsg <- mbOrigMsg
@@ -111,11 +111,11 @@ setGhcCode mbOrigMsg diag =
111111
setGhcCode _ diag = diag
112112
#endif
113113

114-
#if MIN_VERSION_ghc(9,10,1)
114+
#if MIN_VERSION_ghc(9,9,0)
115115
-- DiagnosticCode only got a show instance in 9.10.1
116116
showGhcCode :: DiagnosticCode -> T.Text
117117
showGhcCode = T.pack . show
118-
#elif MIN_VERSION_ghc(9,6,1)
118+
#elif MIN_VERSION_ghc(9,5,0)
119119
showGhcCode :: DiagnosticCode -> T.Text
120120
showGhcCode (DiagnosticCode prefix c) = T.pack $ prefix ++ "-" ++ printf "%05d" c
121121
#endif

0 commit comments

Comments
 (0)