@@ -38,34 +38,36 @@ class ReplCompiler extends Compiler {
3838 List (new PostTyper ),
3939 )
4040
41- def newRun (initCtx : Context , state : State ): Run = new Run ( this , initCtx) {
42-
43- /** Import previous runs and user defined imports */
44- override protected def rootContext (using Context ): Context = {
45- def importContext (imp : tpd.Import )(using Context ) =
46- ctx.importContext(imp, imp.symbol)
47-
48- def importPreviousRun (id : Int )(using Context ) = {
49- // we first import the wrapper object id
50- val path = nme.REPL_PACKAGE ++ " ." ++ objectNames(id)
51- val ctx0 = ctx.fresh
52- .setNewScope
53- .withRootImports(RootRef (() => requiredModuleRef(path)) :: Nil )
54-
55- // then its user defined imports
56- val imports = state.imports.getOrElse(id, Nil )
57- if imports.isEmpty then ctx0
58- else imports.foldLeft(ctx0.fresh.setNewScope)((ctx, imp) =>
59- importContext(imp)(using ctx))
60- }
41+ def newRun (initCtx : Context , state : State ): Run =
42+ val run = new Run ( this , initCtx) {
43+ /** Import previous runs and user defined imports */
44+ override protected def rootContext (using Context ): Context = {
45+ def importContext (imp : tpd.Import )(using Context ) =
46+ ctx.importContext(imp, imp.symbol)
47+
48+ def importPreviousRun (id : Int )(using Context ) = {
49+ // we first import the wrapper object id
50+ val path = nme.REPL_PACKAGE ++ " ." ++ objectNames(id)
51+ val ctx0 = ctx.fresh
52+ .setNewScope
53+ .withRootImports(RootRef (() => requiredModuleRef(path)) :: Nil )
54+
55+ // then its user defined imports
56+ val imports = state.imports.getOrElse(id, Nil )
57+ if imports.isEmpty then ctx0
58+ else imports.foldLeft(ctx0.fresh.setNewScope)((ctx, imp) =>
59+ importContext(imp)(using ctx))
60+ }
6161
62- val rootCtx = super .rootContext
63- .withRootImports // default root imports
64- .withRootImports(RootRef (() => defn.EmptyPackageVal .termRef) :: Nil )
65- (1 to state.objectIndex).foldLeft(rootCtx)((ctx, id) =>
66- importPreviousRun(id)(using ctx))
62+ val rootCtx = super .rootContext
63+ .withRootImports // default root imports
64+ .withRootImports(RootRef (() => defn.EmptyPackageVal .termRef) :: Nil )
65+ (1 to state.objectIndex).foldLeft(rootCtx)((ctx, id) =>
66+ importPreviousRun(id)(using ctx))
67+ }
6768 }
68- }
69+ run.suppressions.initSuspendedMessages(state.context.run)
70+ run
6971
7072 private val objectNames = mutable.Map .empty[Int , TermName ]
7173
0 commit comments