【问题标题】:IntelliJ error with Scala function: "cannot resolve reference format with such signature"Scala 函数的 IntelliJ 错误:“无法解析具有此类签名的引用格式”
【发布时间】:2017-01-23 22:10:46
【问题描述】:
IntelliJ 抱怨此代码:
val document: Node // (initialized further up in the code)
val s: String = (new scala.xml.PrettyPrinter(80, 4)).format(document))
出现错误:
无法解析具有此类签名的参考格式
但是 - 存在这样的功能。第二个参数有一个默认值,似乎 IntelliJ 没有正确识别它。
【问题讨论】:
标签:
scala
intellij-idea
intellij-14
【解决方案1】:
我不确定你提到的那个具体错误,但你有一个括号太多了。你有:
val s: String = (new scala.xml.PrettyPrinter(80, 4)).format(document))
应该是:
val s: String = (new scala.xml.PrettyPrinter(80, 4)).format(document)
我刚刚在sbt 中尝试了您的代码(一旦我进行了更正),它似乎很好:
scala> import scala.xml._
import scala.xml._
scala> val document : Node = <test>blah</test>
document: scala.xml.Node = <test>blah</test>
scala> val s: String = (new PrettyPrinter(80, 4)).format(document)
s: String = <test>blah</test>