Skip to content

Commit 73d6095

Browse files
committed
Simplify REPL language import propagation
Move propagateLanguageImports before compile so that newRun derives the state context from an already-updated rootCtx, eliminating the post-compilation settings sync.
1 parent bde8e74 commit 73d6095

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

repl/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ class ReplDriver(settings: Array[String],
364364
state
365365

366366
case parsed: Parsed if parsed.trees.nonEmpty =>
367+
propagateLanguageImports(parsed.trees)
367368
compile(parsed, state)
368369

369370
case SyntaxErrors(_, errs, _) =>
@@ -406,16 +407,7 @@ class ReplDriver(settings: Array[String],
406407
.fold(
407408
displayErrors,
408409
{
409-
case (unit: CompilationUnit, newState0: State) =>
410-
// Propagate global language imports to rootCtx so subsequent parses see them (i16250).
411-
// We check the parsed trees rather than the compilation unit flags because the REPL
412-
// parses in a separate step that uses a temporary compilation unit.
413-
propagateLanguageImports(parsed.trees)
414-
// Update the state's context settings to match rootCtx so subsequent parsing sees them
415-
val newState =
416-
if newState0.context.settingsState ne rootCtx.settingsState then
417-
newState0.copy(context = newState0.context.fresh.setSettings(rootCtx.settingsState))
418-
else newState0
410+
case (unit: CompilationUnit, newState: State) =>
419411
val newestWrapper = extractNewestWrapper(unit.untpdTree)
420412
val newImports = extractTopLevelImports(newState.context)
421413
var allImports = newState.imports

0 commit comments

Comments
 (0)