From b14a3f845dc572b1cc1b66d55c01473a8dcc0f8b Mon Sep 17 00:00:00 2001 From: fendor Date: Tue, 27 Aug 2019 14:56:27 +0200 Subject: [PATCH] Use compat for older ghcs --- hie-plugin-api/Haskell/Ide/Engine/Compat.hs | 19 +++++++++++++++++++ hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs | 7 +++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/hie-plugin-api/Haskell/Ide/Engine/Compat.hs b/hie-plugin-api/Haskell/Ide/Engine/Compat.hs index 72848ca86..fb172f72d 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Compat.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Compat.hs @@ -134,6 +134,25 @@ pattern FunBindType t <- GHC.FunBind (GHC.L _ (Var.varType -> t)) _ _ _ _ #endif +pattern FunBindGen :: Type.Type -> GHC.MatchGroup GhcTc (GHC.LHsExpr GhcTc) -> GHC.HsBindLR GhcTc GhcTc +pattern FunBindGen t fmatches <- +#if MIN_VERSION_ghc(8, 6, 0) + GHC.FunBind _ (GHC.L _ (Var.varType -> t)) fmatches _ _ +#elif MIN_VERSION_ghc(8, 4, 0) + GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _ +#else + GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _ +#endif + +pattern AbsBinds :: GHC.LHsBinds GhcTc -> GHC.HsBindLR GhcTc GhcTc +pattern AbsBinds bs <- +#if MIN_VERSION_ghc(8, 6, 0) + GHC.AbsBinds _ _ _ _ _ bs _ +#elif MIN_VERSION_ghc(8, 4, 0) + GHC.AbsBinds _ _ _ _ bs _ +#else + GHC.AbsBinds _ _ _ _ bs +#endif #if MIN_VERSION_ghc(8, 6, 0) matchGroupType :: GHC.MatchGroupTc -> GHC.Type diff --git a/hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs b/hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs index 0490cd39b..b3d96f287 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs @@ -12,7 +12,6 @@ import qualified GHC import GHC ( TypecheckedModule, GhcMonad ) import Bag import BasicTypes -import Var import Data.Data as Data import Control.Monad.IO.Class @@ -43,13 +42,13 @@ everythingInTypecheckedSourceM xs = bs processBind :: GhcMonad m => GHC.LHsBindLR Compat.GhcTc Compat.GhcTc -> m TypeMap processBind x@(GHC.L (GHC.RealSrcSpan spn) b) = case b of - GHC.FunBind _ fid fmatches _ _ -> + Compat.FunBindGen t fmatches -> case GHC.mg_origin fmatches of Generated -> return IM.empty FromSource -> do im <- types fmatches - return $ (IM.singleton (rspToInt spn) (varType (GHC.unLoc fid))) `IM.union` im - GHC.AbsBinds _ _ _ _ _ bs _ -> everythingInTypecheckedSourceM bs + return $ IM.singleton (rspToInt spn) t `IM.union` im + Compat.AbsBinds bs -> everythingInTypecheckedSourceM bs _ -> types x processBind _ = return IM.empty