Skip to content

Commit 5cbb512

Browse files
allanrenuccinicolasstucki
authored andcommitted
Fix #4230: Handle import in the REPL correctly
We used to collect imports from the parsed tree and insert them as parsed trees at the top of the REPL wrapper object. This caused members shadowing issues. We now introduce a phase in the REPL compiler that collects imports after type checking and store them as typed tree. We can then create a context with its imports set in the correct order and use it to compile future expressions.
1 parent 377f622 commit 5cbb512

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class ReplDriver(settings: Array[String],
317317
for {
318318
objectIndex <- 1 to state.objectIndex
319319
imp <- state.imports.getOrElse(objectIndex, Nil)
320-
} out.println(imp.show(state.context))
320+
} out.println(SyntaxHighlighting(imp.show(state.context)))
321321
state
322322

323323
case Load(path) =>

0 commit comments

Comments
 (0)