Skip to content

Commit c6debb7

Browse files
authored
Merge pull request #12303 from griggt/fix-11146
Fix #11146: Don't re-add root imports to context in REPLFrontEnd
2 parents affe8d0 + 9b225c1 commit c6debb7

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package repl
44
import dotc.typer.FrontEnd
55
import dotc.CompilationUnit
66
import dotc.core.Contexts._
7-
import dotc.typer.ImportInfo.withRootImports
87

98
/** A customized `FrontEnd` for the REPL
109
*
@@ -19,7 +18,7 @@ private[repl] class REPLFrontEnd extends FrontEnd {
1918
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = {
2019
assert(units.size == 1) // REPl runs one compilation unit at a time
2120
val unit = units.head
22-
val unitContext = ctx.fresh.setCompilationUnit(unit).withRootImports
21+
val unitContext = ctx.fresh.setCompilationUnit(unit)
2322
enterSyms(using unitContext)
2423
typeCheck(using unitContext)
2524
List(unit)

compiler/test-resources/repl/i11146

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
scala> class Appendable { def foo = println("Appendable.foo") }
2+
// defined class Appendable
3+
4+
scala> (new Appendable).foo
5+
Appendable.foo
6+
7+
scala> def assert(x: Boolean) = println(if x then "not asserted" else "asserted")
8+
def assert(x: Boolean): Unit
9+
10+
scala> assert(false)
11+
asserted
12+
13+
scala> class Option; object Option { val baz = 42 }
14+
// defined class Option
15+
// defined object Option
16+
17+
scala> Option.baz
18+
val res0: Int = 42
19+
20+
scala> object fs2 { class Stream[T] { override def toString = "fs2.Stream(..)" }; object Stream { def apply[T](x: T) = new Stream[T] }}
21+
// defined object fs2
22+
23+
scala> import fs2.Stream
24+
scala> Stream(1)
25+
val res1: fs2.Stream[Int] = fs2.Stream(..)

0 commit comments

Comments
 (0)