如何像粘贴一样在 REPL 中加载整个文件

How to load entire file in REPL as with paste

Scala REPL 具有有用的功能 :Load,允许将整个文件导入当前会话。但它给了我警告:

warning: previously defined object Holder is not a companion to trait Holder.

Companions must be defined together; you may wish to use :paste mode for this.

如何加载整个文件以保留 类 和对象之间的伴随关系?

你试过粘贴模式了吗?

scala> :paste myfile.sc

或缩写

scala> :pa myfile.sc

就说:paste myfile.

支持一段时间了。

https://github.com/scala/scala/blame/2.11.x/src/repl/scala/tools/nsc/interpreter/ILoop.scala#L697