From 19ff7c706d0ef7d4274af14afa69110e3cf164fa Mon Sep 17 00:00:00 2001 From: Fendor Date: Mon, 31 Oct 2022 20:09:13 +0100 Subject: [PATCH 1/2] Fix ghc source plugins for GHC 9.2 This is supposed to fix ghc source plugins for GHC 9.4 as well, but I couldn't prove that locally. After GHC 9.0, plugins no longer live in DynFlags, but in HscEnv. Thus, we need to make sure to pass the modified HscEnv to the subsequent typechecking and renaming phase. --- ghcide/src/Development/IDE/Core/Compile.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index 978e0ceccb..4e23d2022b 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -172,18 +172,18 @@ typecheckModule :: IdeDefer typecheckModule (IdeDefer defer) hsc tc_helpers pm = do let modSummary = pm_mod_summary pm dflags = ms_hspp_opts modSummary - mmodSummary' <- catchSrcErrors (hsc_dflags hsc) "typecheck (initialize plugins)" + (mmodSummary') <- catchSrcErrors (hsc_dflags hsc) "typecheck (initialize plugins)" (initPlugins hsc modSummary) case mmodSummary' of Left errs -> return (errs, Nothing) - Right modSummary' -> do + Right (modSummary', hsc') -> do (warnings, etcm) <- withWarnings "typecheck" $ \tweak -> let - session = tweak (hscSetFlags dflags hsc) + session = tweak hsc' -- TODO: maybe settings ms_hspp_opts is unnecessary? mod_summary'' = modSummary' { ms_hspp_opts = hsc_dflags session} in - catchSrcErrors (hsc_dflags hsc) "typecheck" $ do + catchSrcErrors (hsc_dflags session) "typecheck" $ do tcRnModule session tc_helpers $ demoteIfDefer pm{pm_mod_summary = mod_summary''} let errorPipeline = unDefer . hideDiag dflags . tagDiag diags = map errorPipeline warnings @@ -478,7 +478,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do Nothing #endif -#else +#else let !partial_iface = force (mkPartialIface session details simplified_guts) final_iface <- mkFullIface session partial_iface #endif @@ -569,10 +569,10 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do . (("Error during " ++ T.unpack source) ++) . show @SomeException ] -initPlugins :: HscEnv -> ModSummary -> IO ModSummary +initPlugins :: HscEnv -> ModSummary -> IO (ModSummary, HscEnv) initPlugins session modSummary = do session1 <- liftIO $ initializePlugins (hscSetFlags (ms_hspp_opts modSummary) session) - return modSummary{ms_hspp_opts = hsc_dflags session1} + return (modSummary{ms_hspp_opts = hsc_dflags session1}, session1 ) -- | Whether we should run the -O0 simplifier when generating core. -- From e8f4cfee4faa3896a633560a7e056fe07a41c546 Mon Sep 17 00:00:00 2001 From: Fendor Date: Mon, 31 Oct 2022 20:24:56 +0100 Subject: [PATCH 2/2] Enable simple plugin test --- ghcide/test/exe/Main.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index accfade90e..235c2db156 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1187,7 +1187,6 @@ checkFileCompiles fp diag = pluginSimpleTests :: TestTree pluginSimpleTests = ignoreInWindowsForGHC810 $ - ignoreForGHC92Plus "blocked on ghc-typelits-natnormalise" $ testSessionWithExtraFiles "plugin-knownnat" "simple plugin" $ \dir -> do _ <- openDoc (dir "KnownNat.hs") "haskell" liftIO $ writeFile (dir"hie.yaml")