Closed
Description
This is encountered when working with ScalaTest test set.
minimized code
trait StringTempl {
def mkString: String
def mkString(x: String): String
}
object Test {
def (x: String) shouldBe(y: String): Boolean = ???
def test(tmpl: StringTempl): Unit = {
tmpl.mkString shouldBe "hello" // error
tmpl.mkString(", world") shouldBe "hello, world"
}
}
The compiler reports an error:
-- [E134] Type Mismatch Error: examples/apply.scala:11:9 -----------------------
11 | tmpl.mkString shouldBe "hello"
| ^^^^^^^^^^^^^
|None of the overloaded alternatives of method mkString in trait StringTempl with types
| (x: String): String
| => String
|match expected type ?{ shouldBe: ? }
expectation
The compiler should accept the code without reporting an error.