【问题标题】:Embedding scala 2.13.x REPL嵌入 scala 2.13.x REPL
【发布时间】:2020-05-05 06:04:27
【问题描述】:

对于 Scala 2.12.x,可以使用 scala.tools.nsc.interpreter.ILoop 嵌入 Scala REPL。对于 Scala 2.13.xscala.tools.nsc.interpreter.ILoop 已被删除。如何嵌入 Scala 2.13.x REPL?

【问题讨论】:

    标签: scala scala-repl scala-2.13


    【解决方案1】:

    尝试添加scala-compiler依赖

    libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.13.1"
    

    之后,例如,以下编译

    import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig}
    import scala.tools.nsc._
    
    object EmbeddedREPL extend App {
      val settings = new Settings {
        usejavacp.value = true
        deprecation.value = true
      }
      val config = ShellConfig(settings)
      new ILoop(config).run(settings)
    }
    

    【讨论】:

      猜你喜欢
      • 2020-02-22
      • 1970-01-01
      • 2021-09-29
      • 2013-09-08
      • 2017-07-18
      • 1970-01-01
      • 2015-08-14
      • 1970-01-01
      相关资源
      最近更新 更多