Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Compat with GHC < 8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Aug 23, 2020
1 parent 79370e4 commit f226ae0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/Development/IDE/Core/Preprocessor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import qualified HeaderInfo as Hdr
import Development.IDE.Types.Diagnostics
import Development.IDE.Types.Location
import Development.IDE.GHC.Error
import Development.IDE.GHC.Util
import SysTools (Option (..), runUnlit, runPp)
import Control.Monad.Trans.Except
import qualified GHC.LanguageExtensions as LangExt
Expand Down
15 changes: 13 additions & 2 deletions src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ module Development.IDE.GHC.Compat(
Module.addBootSuffix,
pattern ModLocation,
getConArgs,

HasSrcSpan,
getLoc,

upNameCache,
disableWarningsAsErrors,

module GHC,
#if MIN_GHC_API_VERSION(8,6,0)
Expand Down Expand Up @@ -100,6 +99,7 @@ import GHC hiding (
)
import qualified HeaderInfo as Hdr
import Avail
import Data.List (foldl')
import ErrUtils (ErrorMessages)
import FastString (FastString)

Expand All @@ -119,6 +119,7 @@ import System.FilePath ((-<.>))
#endif

#if !MIN_GHC_API_VERSION(8,8,0)
import qualified EnumSet

#if MIN_GHC_API_VERSION(8,6,0)
import GhcPlugins (srcErrorMessages)
Expand Down Expand Up @@ -398,3 +399,13 @@ getConArgs = GHC.getConDetails

getPackageName :: DynFlags -> Module.InstalledUnitId -> Maybe PackageName
getPackageName dfs i = packageName <$> lookupPackage dfs (Module.DefiniteUnitId (Module.DefUnitId i))

disableWarningsAsErrors :: DynFlags -> DynFlags
disableWarningsAsErrors df =
flip gopt_unset Opt_WarnIsError $ foldl' wopt_unset_fatal df [toEnum 0 ..]

#if !MIN_GHC_API_VERSION(8,8,0)
wopt_unset_fatal :: DynFlags -> WarningFlag -> DynFlags
wopt_unset_fatal dfs f
= dfs { fatalWarningFlags = EnumSet.delete f (fatalWarningFlags dfs) }
#endif
7 changes: 1 addition & 6 deletions src/Development/IDE/GHC/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import Outputable (showSDocUnsafe, ppr, showSDoc, Outputable)
import Packages (getPackageConfigMap, lookupPackage')
import SrcLoc (mkRealSrcLoc)
import FastString (mkFastString)
import DynFlags (wopt_unset_fatal, gopt_unset, emptyFilesToClean, unsafeGlobalDynFlags)
import DynFlags (emptyFilesToClean, unsafeGlobalDynFlags)
import Module (moduleNameSlashes, InstalledUnitId)
import OccName (parenSymOcc)
import RdrName (nameRdrName, rdrNameOcc)
Expand Down Expand Up @@ -300,8 +300,3 @@ ioe_dupHandlesNotCompatible :: Handle -> IO a
ioe_dupHandlesNotCompatible h =
ioException (IOError (Just h) IllegalOperation "hDuplicateTo"
"handles are incompatible" Nothing Nothing)


disableWarningsAsErrors :: DynFlags -> DynFlags
disableWarningsAsErrors df = flip gopt_unset Opt_WarnIsError
$ foldl' wopt_unset_fatal df [toEnum 0 ..]

0 comments on commit f226ae0

Please sign in to comment.