diff options
-rw-r--r-- | compiler/main/HscMain.hs | 20 | ||||
-rw-r--r-- | compiler/main/HscTypes.hs | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index 3c4b92b3de..328655c6d0 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -1467,7 +1467,6 @@ hscDeclsWithLocation hsc_env0 str source linenumber = -- been done. See the notes at the definition of InteractiveContext -- (ic_instances) for more details. let defaults = tcg_default tc_gblenv - let fix_env = tcg_fix_env tc_gblenv {- Desugar it -} -- We use a basically null location for iNTERACTIVE @@ -1521,10 +1520,29 @@ hscDeclsWithLocation hsc_env0 str source linenumber = new_tythings = map AnId ext_ids ++ map ATyCon tcs ++ map (AConLike . PatSynCon) patsyns ictxt = hsc_IC hsc_env + -- See Note [Fixity declarations in GHCi] + fix_env = tcg_fix_env tc_gblenv new_ictxt = extendInteractiveContext ictxt new_tythings cls_insts fam_insts defaults fix_env return (new_tythings, new_ictxt) + +{- + Note [Fixity declarations in GHCi] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + To support fixity declarations on types defined within GHCi (as requested + in #10018) we record the fixity environment in InteractiveContext. + When we want to evaluate something TcRnDriver.runTcInteractive pulls out this + fixity environment and uses it to initialize the global typechecker environment. + After the typechecker has finished its business, an updated fixity environment + (reflecting whatever fixity declarations were present in the statements we + passed it) will be returned from hscParsedStmt. This is passed to + updateFixityEnv, which will stuff it back into InteractiveContext, to be + used in evaluating the next statement. + +-} + hscImport :: HscEnv -> String -> IO (ImportDecl RdrName) hscImport hsc_env str = runInteractiveHsc hsc_env $ do (L _ (HsModule{hsmodImports=is})) <- diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs index f05dbdd93a..7bceda50f6 100644 --- a/compiler/main/HscTypes.hs +++ b/compiler/main/HscTypes.hs @@ -1436,7 +1436,7 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults , ic_instances = ( new_cls_insts ++ old_cls_insts , new_fam_insts ++ old_fam_insts ) , ic_default = defaults - , ic_fix_env = fix_env -- # 10018 + , ic_fix_env = fix_env -- See Note [Fixity declarations in GHCi] } where new_ids = [id | AnId id <- new_tythings] |