No, the script runner wraps your code as local to a synthetic "main" method. The REPL wraps each line in a separate class instance or singleton object which is imported into subsequent lines as necessary.
Use -Xprint:parser,typer, or // show in REPL.
$ scala -nc -Xprint:parser,typer h.scala
[[syntax trees at end of parser]] // h.scala
package <empty> {
object Main extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
def main(args: Array[String]): scala.Unit = {
final class $anon extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
println("hello, world")
};
new $anon()
}
}
}
compare to:
$ scala -Xprint:parser
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.
scala> println("hello, world.")
[[syntax trees at end of parser]] // <console>
package $line3 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val res0 = println("hello, world.")
}
}
}
}