diff options
| author | Sylvain Henry <sylvain@haskus.fr> | 2021-12-14 11:23:02 +0100 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-12-21 01:46:39 -0500 |
| commit | 9728d6c2b62f38f79c8833b1819200985fe173dc (patch) | |
| tree | 8e44abae10080473b22ad71f750613cdc1fa9a96 /compiler/GHC/Tc | |
| parent | 00b55bfcd982bed2c9fc02d9c3ca66ba9d41bb5c (diff) | |
| download | haskell-9728d6c2b62f38f79c8833b1819200985fe173dc.tar.gz | |
Give plugins a better interface (#17957)
Plugins were directly fetched from HscEnv (hsc_static_plugins and
hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable
and it's better to store them in a new Plugins datatype and to use it in
the plugins' API (e.g. withPlugins, mapPlugins...).
In the process, the interactive context (used by GHCi) got proper
support for different static plugins than those used for loaded modules.
Bump haddock submodule
Diffstat (limited to 'compiler/GHC/Tc')
| -rw-r--r-- | compiler/GHC/Tc/Gen/Splice.hs | 2 | ||||
| -rw-r--r-- | compiler/GHC/Tc/Module.hs | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs index 9ddff4213b..bba7eeaedc 100644 --- a/compiler/GHC/Tc/Gen/Splice.hs +++ b/compiler/GHC/Tc/Gen/Splice.hs @@ -994,7 +994,7 @@ runMeta' show_code ppr_hs run_and_convert expr -- run plugins ; hsc_env <- getTopEnv - ; expr' <- withPlugins hsc_env spliceRunAction expr + ; expr' <- withPlugins (hsc_plugins hsc_env) spliceRunAction expr -- Desugar ; (ds_msgs, mb_ds_expr) <- initDsTc (dsLExpr expr') diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs index 06270c1848..68bfba4448 100644 --- a/compiler/GHC/Tc/Module.hs +++ b/compiler/GHC/Tc/Module.hs @@ -3071,7 +3071,7 @@ Type Checker Plugins withTcPlugins :: HscEnv -> TcM a -> TcM a withTcPlugins hsc_env m = - case catMaybes $ mapPlugins hsc_env tcPlugin of + case catMaybes $ mapPlugins (hsc_plugins hsc_env) tcPlugin of [] -> m -- Common fast case plugins -> do ev_binds_var <- newTcEvBinds @@ -3096,7 +3096,7 @@ withTcPlugins hsc_env m = withDefaultingPlugins :: HscEnv -> TcM a -> TcM a withDefaultingPlugins hsc_env m = - do case catMaybes $ mapPlugins hsc_env defaultingPlugin of + do case catMaybes $ mapPlugins (hsc_plugins hsc_env) defaultingPlugin of [] -> m -- Common fast case plugins -> do (plugins,stops) <- mapAndUnzipM start_plugin plugins -- This ensures that dePluginStop is called even if a type @@ -3114,7 +3114,7 @@ withDefaultingPlugins hsc_env m = withHoleFitPlugins :: HscEnv -> TcM a -> TcM a withHoleFitPlugins hsc_env m = - case catMaybes $ mapPlugins hsc_env holeFitPlugin of + case catMaybes $ mapPlugins (hsc_plugins hsc_env) holeFitPlugin of [] -> m -- Common fast case plugins -> do (plugins,stops) <- mapAndUnzipM start_plugin plugins -- This ensures that hfPluginStop is called even if a type @@ -3136,7 +3136,7 @@ runRenamerPlugin :: TcGblEnv -> TcM (TcGblEnv, HsGroup GhcRn) runRenamerPlugin gbl_env hs_group = do hsc_env <- getTopEnv - withPlugins hsc_env + withPlugins (hsc_plugins hsc_env) (\p opts (e, g) -> ( mark_plugin_unsafe (hsc_dflags hsc_env) >> renamedResultAction p opts e g)) (gbl_env, hs_group) @@ -3159,7 +3159,7 @@ getRenamedStuff tc_result runTypecheckerPlugin :: ModSummary -> TcGblEnv -> TcM TcGblEnv runTypecheckerPlugin sum gbl_env = do hsc_env <- getTopEnv - withPlugins hsc_env + withPlugins (hsc_plugins hsc_env) (\p opts env -> mark_plugin_unsafe (hsc_dflags hsc_env) >> typeCheckResultAction p opts sum env) gbl_env |
