From 1ad605db6ca94cdc8caff6eb9c98acd414a54b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Facundo=20Dom=C3=ADnguez?= Date: Wed, 30 Oct 2024 17:04:41 +0000 Subject: [PATCH] Remove unneeded TyThing lookup method --- .../src-ghc/Liquid/GHC/API/Extra.hs | 24 ------------------- .../Language/Haskell/Liquid/GHC/Interface.hs | 3 --- 2 files changed, 27 deletions(-) diff --git a/liquidhaskell-boot/src-ghc/Liquid/GHC/API/Extra.hs b/liquidhaskell-boot/src-ghc/Liquid/GHC/API/Extra.hs index 05b6425163..6e112257fb 100644 --- a/liquidhaskell-boot/src-ghc/Liquid/GHC/API/Extra.hs +++ b/liquidhaskell-boot/src-ghc/Liquid/GHC/API/Extra.hs @@ -14,8 +14,6 @@ module Liquid.GHC.API.Extra ( , fsToUnitId , isPatErrorAlt , minus_RDR - , modInfoLookupName - , moduleInfoTc , qualifiedNameFS , renderWithStyle , showPprQualified @@ -28,7 +26,6 @@ module Liquid.GHC.API.Extra ( , untick ) where -import Control.Monad.IO.Class import Liquid.GHC.API.StableModule as StableModule import GHC hiding (modInfoLookupName) import Data.Data (Data, gmapQr, gmapT) @@ -45,8 +42,6 @@ import GHC.Core.Type as Ghc hiding (typeKind , isPredTy, extend import GHC.Data.FastString as Ghc import GHC.Data.Maybe import qualified GHC.Data.Strict -import GHC.Driver.Env -import GHC.Driver.Main import GHC.Driver.Session as Ghc import GHC.Tc.Types import GHC.Types.Id @@ -54,10 +49,8 @@ import GHC.Types.Basic import GHC.Types.Name (isSystemName, nameModule_maybe, occNameFS) import GHC.Types.Name.Reader (nameRdrName) import GHC.Types.SrcLoc as Ghc -import GHC.Types.TypeEnv import GHC.Types.Unique (getUnique, hasKey) -import GHC.Unit.Module.ModDetails (md_types) import GHC.Utils.Outputable as Ghc hiding ((<>)) import GHC.Unit.Module @@ -176,23 +169,6 @@ addNoInlinePragmasToBinds tcg = tcg{ tcg_binds = go (tcg_binds tcg) } { abe_poly = markId poly , abe_mono = markId mono } - --- | Our own simplified version of 'ModuleInfo' to overcome the fact we cannot construct the \"original\" --- one as the constructor is not exported, and 'getHomeModuleInfo' and 'getPackageModuleInfo' are not --- exported either, so we had to backport them as well. -newtype ModuleInfoLH = ModuleInfoLH { minflh_type_env :: TypeEnv } - -modInfoLookupName :: (GhcMonad m) => ModuleInfoLH -> Name -> m (Maybe TyThing) -modInfoLookupName minf name = do - case lookupTypeEnv (minflh_type_env minf) name of - Just tyThing -> return (Just tyThing) - Nothing -> lookupGlobalName name - -moduleInfoTc :: HscEnv -> TcGblEnv -> IO ModuleInfoLH -moduleInfoTc hscEnv tcGblEnv = do - details <- md_types <$> liftIO (makeSimpleDetails (hsc_logger hscEnv) tcGblEnv) - pure ModuleInfoLH { minflh_type_env = details } - -- | Tells if a case alternative calls to patError isPatErrorAlt :: CoreAlt -> Bool isPatErrorAlt (Alt _ _ exprCoreBndr) = hasPatErrorCall exprCoreBndr diff --git a/liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs b/liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs index d57ebb7cf3..46bf67f976 100644 --- a/liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs +++ b/liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs @@ -179,12 +179,9 @@ lookupTyThings tcGblEnv = mapM (lookupTyThing tcGblEnv) names lookupTyThing :: (GhcMonad m) => TcGblEnv -> Name -> m (Name, Maybe TyThing) lookupTyThing tcGblEnv name = do - hscEnv <- getSession mbTy <- runMaybeT . msum . map MaybeT $ [ pure (lookupNameEnv (tcg_type_env tcGblEnv) name) , lookupName name - , do minf <- liftIO $ moduleInfoTc hscEnv tcGblEnv - modInfoLookupName minf name ] return (name, mbTy)