0
以下:暧昧参考超载定义
object SomeObj {
def addVertex(cc: Product): String = ???
def addVertex(cc: AnyRef): String = ???
}
case class Toto(s: String)
SomeObj.addVertex(Toto(""))
做:
Error:(8, 10) ambiguous reference to overloaded definition,
both method addVertex in object SomeObj of type (cc: Object)String
and method addVertex in object SomeObj of type (cc: Product)String
match argument types (A$A34.this.Toto)
SomeObj.addVertex(Toto(""));}
^
为什么?不应该为最具体的一个?
有趣的是Any
而不是AnyRef
它的作品。
干杯
不是真的,你的例子对我没有提及的错误。你使用的是什么版本的Scala? – Mifeet