Skip to content

Incorrect overloading resolution involving parameterless method #6705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
liufengyun opened this issue Jun 18, 2019 · 0 comments
Closed

Incorrect overloading resolution involving parameterless method #6705

liufengyun opened this issue Jun 18, 2019 · 0 comments

Comments

@liufengyun
Copy link
Contributor

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.

@odersky odersky self-assigned this Jun 24, 2019
@odersky odersky closed this as completed in 8a725f3 Aug 2, 2019
odersky added a commit that referenced this issue Aug 2, 2019
Fix #6705: Improve adaptation of overloaded terms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants