I know there are a number of other questions about this error, but the others are pretty clear why there's an error. In my case, I can't understand why. Here's a short example:
trait A {
def text: String = "abc"
}
case object B extends A {
def text(s: Seq[String]): String = s.mkString
}
Now, calling B.text I would expect to be unambiguously resolved to the method inherited from the base trait since the one in object B doesn't even match the calling signature... but yet, error!
<console>:13: error: ambiguous reference to overloaded definition,
both method text in object B of type (s: Seq[String])String
and method text in trait A of type => String
match expected type ?
B.text
^
Is this "normal"/expected?
B.text can be considered on the one hand as calling text method from trait A and on the other hand as eta-expanded method from B that will return the function of type Seq[String] => String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With