Fix #11146: Don't re-add root imports to context in REPLFrontEnd #12303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The root context for REPL compiler runs is initialized by
ReplCompiler#newRun
,which contains special handling to:
java.lang._
,scala._
,Predef._
)The result is the innermost context imports the most recent REPL wrapper
and the (nearly) outermost contexts contain the default imports.
Before this commit, the default root imports were also being added to the
(innermost) context in
REPLFrontEnd#runOn
, resulting in REPL definitionsbeing shadowed by those in
java.lang._
,scala._
andPredef._
The context before this PR as seen by the frontend would look something like the below (this is after two previous lines of REPL input.) Note the undesirable imports of
java.lang._
,scala._
andPredef._
in the innermost contexts.Fixes #11146
Fixes #9720