From e55e9561b51bd525cf5f97f8dc2053ba7f2aecf4 Mon Sep 17 00:00:00 2001 From: eagletmt Date: Mon, 1 Apr 2013 15:59:53 +0900 Subject: [PATCH] Disable fast check when QuasiQuotes is used --- Debug.hs | 3 +-- GHCApi.hs | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Debug.hs b/Debug.hs index b7280f6..2f28235 100644 --- a/Debug.hs +++ b/Debug.hs @@ -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 diff --git a/GHCApi.hs b/GHCApi.hs index 35d2529..da87ef7 100644 --- a/GHCApi.hs +++ b/GHCApi.hs @@ -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]