on master help sign in
GHC 8.6 compat for the IDE (#955)

* I have no idea now LPat and Pat previously managed to unify... * Avoid using unRealSrcSpan as its only introduced for GHC 8.8 * Add some CPP to permit compiling with GHC 8.6 * Permit CPP in one more place

commitc0e9c9042972404120b7f1764bd2aa2538f54a3b authorNeil Mitchell <35463327+neil-da@users.noreply.github.com> dateMon 6 May 2019, 21:29 (7 years ago) parentb9dfd49
3 files changed+12−2
src/Development/IDE/Functions/Compile.hs+10 src/Development/IDE/Functions/Documentation.hs+1−1 src/Development/IDE/Functions/SpanInfo.hs+1−1
src/Development/IDE/Functions/Compile.hs+10
@@ -3,6 +3,7 @@
33
44{-# LANGUAGE OverloadedStrings #-}
55{-# LANGUAGE RankNTypes #-}
6+{-# LANGUAGE CPP #-}
67
78-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
89-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
@@ -414,7 +415,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
414415 { ml_hs_file = Just fp
415416 , ml_hi_file = replaceExtension fp "hi"
416417 , ml_obj_file = replaceExtension fp "o"
418+#ifndef USE_GHC
417419 , ml_hie_file = replaceExtension fp "hie"
420+#endif
418421 -- This does not consider the dflags configuration
419422 -- (-osuf and -hisuf, object and hi dir.s).
420423 -- However, we anyway don't want to generate them.
@@ -433,7 +436,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
433436 , ms_hsc_src = HsSrcFile
434437 , ms_obj_date = Nothing
435438 , ms_iface_date = Nothing
439+#ifndef USE_GHC
436440 , ms_hie_date = Nothing
441+#endif
437442 , ms_srcimps = [] -- source imports are not allowed
438443 , ms_parsed_mod = Nothing
439444 }
@@ -450,8 +455,13 @@ parseFileContents preprocessor filename (time, contents) = do
450455 let loc = mkRealSrcLoc (mkFastString filename) 1 1
451456 dflags <- parsePragmasIntoDynFlags filename contents
452457 case unP Parser.parseModule (mkPState dflags contents loc) of
458+#ifdef USE_GHC
459+ PFailed getMessages _ _ ->
460+ Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
461+#else
453462 PFailed s ->
454463 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
464+#endif
455465 POk pst rdr_module ->
456466 let hpm_annotations =
457467 (Map.fromListWith (++) $ annotations pst,
src/Development/IDE/Functions/Documentation.hs+1−1
@@ -80,7 +80,7 @@ getDocumentation targetName tcs = fromMaybe [] $ do
8080-- | Shows this part of the documentation
8181docHeaders :: [RealLocated AnnotationComment]
8282 -> [T.Text]
83−docHeaders = mapMaybe (wrk . unRealSrcSpan)
83+docHeaders = mapMaybe (\(L _ x) -> wrk x)
8484 where
8585 wrk = \case
8686 AnnDocCommentNext s -> Just $ T.pack s
src/Development/IDE/Functions/SpanInfo.hs+1−1
@@ -36,7 +36,7 @@ getSpanInfo mods tcm =
3636 do let tcs = tm_typechecked_source tcm
3737 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
3838 es = listifyAllSpans tcs :: [LHsExpr GhcTc]
39− ps = listifyAllSpans' tcs :: [LPat GhcTc]
39+ ps = listifyAllSpans' tcs :: [Pat GhcTc]
4040 bts <- mapM (getTypeLHsBind tcm) bs -- binds
4141 ets <- mapM (getTypeLHsExpr tcm) es -- expressions
4242 pts <- mapM (getTypeLPat tcm) ps -- patterns