diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index 04b0823db41c7380c040a5d3ccf99872872e960d..748f7480ec249126532eb2fdb2bf053356e26ece 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -1357,11 +1357,7 @@ hscStmtWithLocation hsc_env0 stmt source linenumber = Just parsed_stmt -> do -- Rename and typecheck it hsc_env <- getHscEnv - let interactive_hsc_env = setInteractivePackage hsc_env - -- Bindings created here belong to the interactive package - -- See Note [The interactive package] in HscTypes - -- (NB: maybe not necessary, since Stmts bind only Ids) - (ids, tc_expr, fix_env) <- ioMsgMaybe $ tcRnStmt interactive_hsc_env parsed_stmt + (ids, tc_expr, fix_env) <- ioMsgMaybe $ tcRnStmt hsc_env parsed_stmt -- Desugar it ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr @@ -1397,10 +1393,7 @@ hscDeclsWithLocation hsc_env0 str source linenumber = {- Rename and typecheck it -} hsc_env <- getHscEnv - let interactive_hsc_env = setInteractivePackage hsc_env - -- Bindings created here belong to the interactive package - -- See Note [The interactive package] in HscTypes - tc_gblenv <- ioMsgMaybe $ tcRnDeclsi interactive_hsc_env decls + tc_gblenv <- ioMsgMaybe $ tcRnDeclsi hsc_env decls {- Grab the new instances -} -- We grab the whole environment because of the overlapping that may have diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs index c4c5efd43c080970fdf54fb9a7dc6a4cfe11d08f..6fcf8e24a7245e2f4adcc89e2ecc4ff876d8b6b2 100644 --- a/compiler/main/HscTypes.lhs +++ b/compiler/main/HscTypes.lhs @@ -1140,10 +1140,13 @@ The details are a bit tricky though: package to which :load'ed modules are added to. * So how do we arrange that declarations at the command prompt get - to be in the 'interactive' package? By setting 'thisPackage' just - before the typecheck/rename step for command-line processing; - see the calls to HscTypes.setInteractivePackage in - HscMain.hscDeclsWithLocation and hscStmtWithLocation. + to be in the 'interactive' package? Simply by setting the tcg_mod + field of the TcGblEnv to "interactive:Ghci1". This is done by the + call to initTc in initTcInteractive, initTcForLookup, which in + turn get the module from it 'icInteractiveModule' field of the + interactive context. + + The 'thisPackage' field stays as 'main' (or whatever -package-name says. * The main trickiness is that the type environment (tcg_type_env and fixity envt (tcg_fix_env) now contains entities from all the