scala tools nsc:在编译器设置中设置编译器标志

时间:2014-06-05 12:24:30

标签: scala scala-compiler

我有以下代码:

def compile(target: String, srcs: Seq[String]): Unit = 
{
  import scala.tools.nsc._
  val settings = new Settings      
  settings.outputDirs.setSingleOutput(target)      
  val comp = new Global(settings)
  val crun: comp.Run  = new comp.Run      
  crun.compile(srcs.toList.flatMap(getFilesList))      
}
def getFilesList(fName: String): List[String] =
{
  val file = new java.io.File(fName)
  if (file.isDirectory) file.listFiles.toList.flatMap(i => getFilesList(fName / i.getName))
  else List(fName)
}

我想添加弃用,功能警告并明确启用隐式转换和宏。

1 个答案:

答案 0 :(得分:0)

使用Lukas Rytz的评论(谢谢)这似乎有效:

settings.processArgumentString(
  "-feature -language implicitConversions  experimental.macros")