I assume that the class you are testing is written in Java, since you need to get out of the way to create only a package member in Scala.
In short, this is not possible. Each line in the REPL is wrapped in its own package, so it will not be allowed access to another member only for packages from any other package. Despite the lack of an undocumented system property for changing the default package name prefix used for packaging, the package name is still generated automatically, increasing the number:
$ scala -Xprint:parser -Dscala.repl.naming.line=foo.line scala> val x = 1 [[syntax trees at end of parser]]// Scala source: <console> package foo.line1 { object $read extends scala.ScalaObject { // snip ... object $iw extends scala.ScalaObject { // snip ... object $iw extends scala.ScalaObject { // snip ... val x = 1 } } }
Assuming you do this often, you can create a file that makes it easier to use reflection, and then load it into the REPL with the command :load
.
source share