@@ -218,6 +218,11 @@ getParsedModuleRule =
218218 mainParse = getParsedModuleDefinition hsc opt file ms
219219 reset_ms pm = pm { pm_mod_summary = ms' }
220220
221+ #if MIN_VERSION_ghc(9,0,1)
222+ -- We no longer need to parse again if GHC version is above 9.0
223+ -- https://github.com/haskell/haskell-language-server/issues/1892
224+ res@ (_,pmod) <- liftIO $ (fmap . fmap . fmap ) reset_ms mainParse
225+ #else
221226 -- Parse again (if necessary) to capture Haddock parse errors
222227 res@ (_,pmod) <- if gopt Opt_Haddock dflags
223228 then
@@ -245,6 +250,7 @@ getParsedModuleRule =
245250 -- This seems to be the correct behaviour because the Haddock flag is added
246251 -- by us and not the user, so our IDE shouldn't stop working because of it.
247252 _ -> pure (diagsM, res)
253+ #endif
248254 -- Add dependencies on included files
249255 _ <- uses GetModificationTime $ map toNormalizedFilePath' (maybe [] pm_extra_src_files pmod)
250256 pure res
@@ -892,12 +898,17 @@ regenerateHiFile sess f ms compNeeded = do
892898
893899 -- Embed haddocks in the interface file
894900 (diags, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f (withOptHaddock ms)
901+ #if MIN_VERSION_ghc(9,0,1)
902+ -- We no longer need to parse again if GHC version is above 9.0
903+ -- https://github.com/haskell/haskell-language-server/issues/1892
904+ #else
895905 (diags, mb_pm) <- case mb_pm of
896906 Just _ -> return (diags, mb_pm)
897907 Nothing -> do
898908 -- if parsing fails, try parsing again with Haddock turned off
899909 (diagsNoHaddock, mb_pm) <- liftIO $ getParsedModuleDefinition hsc opt f ms
900910 return (mergeParseErrorsHaddock diagsNoHaddock diags, mb_pm)
911+ #endif
901912 case mb_pm of
902913 Nothing -> return (diags, Nothing )
903914 Just pm -> do
0 commit comments