diff --git a/compiler/src/dotty/tools/repl/ReplFrontEnd.scala b/compiler/src/dotty/tools/repl/ReplFrontEnd.scala index 59df49e853cb..4eb983e7f674 100644 --- a/compiler/src/dotty/tools/repl/ReplFrontEnd.scala +++ b/compiler/src/dotty/tools/repl/ReplFrontEnd.scala @@ -4,7 +4,6 @@ package repl import dotc.typer.FrontEnd import dotc.CompilationUnit import dotc.core.Contexts._ -import dotc.typer.ImportInfo.withRootImports /** A customized `FrontEnd` for the REPL * @@ -19,7 +18,7 @@ private[repl] class REPLFrontEnd extends FrontEnd { override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = { assert(units.size == 1) // REPl runs one compilation unit at a time val unit = units.head - val unitContext = ctx.fresh.setCompilationUnit(unit).withRootImports + val unitContext = ctx.fresh.setCompilationUnit(unit) enterSyms(using unitContext) typeCheck(using unitContext) List(unit) diff --git a/compiler/test-resources/repl/i11146 b/compiler/test-resources/repl/i11146 new file mode 100644 index 000000000000..1a6b7d414eeb --- /dev/null +++ b/compiler/test-resources/repl/i11146 @@ -0,0 +1,25 @@ +scala> class Appendable { def foo = println("Appendable.foo") } +// defined class Appendable + +scala> (new Appendable).foo +Appendable.foo + +scala> def assert(x: Boolean) = println(if x then "not asserted" else "asserted") +def assert(x: Boolean): Unit + +scala> assert(false) +asserted + +scala> class Option; object Option { val baz = 42 } +// defined class Option +// defined object Option + +scala> Option.baz +val res0: Int = 42 + +scala> object fs2 { class Stream[T] { override def toString = "fs2.Stream(..)" }; object Stream { def apply[T](x: T) = new Stream[T] }} +// defined object fs2 + +scala> import fs2.Stream +scala> Stream(1) +val res1: fs2.Stream[Int] = fs2.Stream(..)