Disable fast check when QuasiQuotes is used

This commit is contained in:
eagletmt 2013-04-01 15:59:53 +09:00
parent 4b77af102b
commit e55e9561b5
2 changed files with 10 additions and 4 deletions

View File

@ -25,8 +25,7 @@ debug opt cradle ver fileName = do
[fast] <- withGHC fileName $ do
void $ initializeFlagsWithCradle opt cradle gopts True
setTargetFile fileName
slow <- needsTemplateHaskell <$> depanal [] False
return [not slow]
pure . canCheckFast <$> depanal [] False
return [
"GHC version: " ++ ver
, "Current directory: " ++ currentDir

View File

@ -7,6 +7,7 @@ module GHCApi (
, getDynamicFlags
, setSlowDynFlags
, checkSlowAndSet
, canCheckFast
) where
import CabalApi
@ -128,8 +129,8 @@ setSlowDynFlags = (flip setFastOrNot Slow <$> getSessionDynFlags)
-- So, this is necessary redundancy.
checkSlowAndSet :: Ghc ()
checkSlowAndSet = do
slow <- needsTemplateHaskell <$> depanal [] False
when slow setSlowDynFlags
fast <- canCheckFast <$> depanal [] False
unless fast setSlowDynFlags
----------------------------------------------------------------
@ -150,3 +151,9 @@ setTargetFile file = do
getDynamicFlags :: IO DynFlags
getDynamicFlags = runGhc (Just libdir) getSessionDynFlags
canCheckFast :: ModuleGraph -> Bool
canCheckFast = not . any (hasTHorQQ . ms_hspp_opts)
where
hasTHorQQ :: DynFlags -> Bool
hasTHorQQ dflags = any (\opt -> xopt opt dflags) [Opt_TemplateHaskell, Opt_QuasiQuotes]