Skip to content

Overloading doesn't work with given args as first param list and functions as args #7793

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
anatoliykmetyuk opened this issue Dec 17, 2019 · 0 comments

Comments

@anatoliykmetyuk
Copy link
Contributor

minimized code

trait Foo
  def g(f: Int => Int): Int = 1
  def g(given String)(f: Int => String): String = "2"

@main def Test =
  val m: Foo = ???
  given String = "foo"
  m.g(x => "2")
-- [E007] Type Mismatch Error: /Users/kmetiuk/Projects/scala3/pg/sandbox/iss71.scala:8:11
8 |  m.g(x => "2")
  |           ^^^
  |           Found:    ("2" : String)
  |           Required: Int
1 error found

Works if you define the second g as (move the given to the last arg group):

  def g(f: Int => String)(given String): String = "2"

Works also if you define gs as:

  def g(f: Int): Int = 1
  def g(given String)(f: String): String = "2"

And use as m.g("2").

Works also if you call m.g(x => 1).

expectation

The original case should resolve overloading correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment