Skip to content

Nested overload resolution fails when splitting argument list #23011

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

Open
EugeneFlesselle opened this issue Apr 17, 2025 · 0 comments · May be fixed by #23012
Open

Nested overload resolution fails when splitting argument list #23011

EugeneFlesselle opened this issue Apr 17, 2025 · 0 comments · May be fixed by #23012

Comments

@EugeneFlesselle
Copy link
Contributor

Compiler version

Scala compiler version 3.7.1-RC1-bin-SNAPSHOT-nonbootstrapped-git-ac47299

Minimized code

type X = Double => Unit
def g(x: Double): Unit = ???
def g(x: String): Unit = ???

def f1(x: X) = ???

def f2(x: X, y: Int) = ???
def f2(x: X, y: Boolean) = ???

def f3(x: X)(y: Int) = ???
def f3(x: X)(y: Boolean) = ???

val r1 = f1(g) // ok
val r2 = f2(g, 1) // ok
val r3 = f3(g)(1) // error ambiguous overload for g

Output

-- [E051] Reference Error: tests/playground/example.scala:17:12 ----------------
17 |val r3 = f3(g)(1) // error ambiguous overload for g
   |            ^
   |  Ambiguous overload. The overloaded alternatives of method g with types
   |   (x: String): Unit
   |   (x: Double): Unit
   |  both match expected type <?>
   |
   | longer explanation available when compiling with `-explain`

Expectation

Ideally, all should be resolved unambiguously.

@EugeneFlesselle EugeneFlesselle added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 17, 2025
@EugeneFlesselle EugeneFlesselle self-assigned this Apr 17, 2025
@EugeneFlesselle EugeneFlesselle added area:overloading itype:enhancement and removed stat:needs triage Every issue needs to have an "area" and "itype" label itype:bug labels Apr 17, 2025
EugeneFlesselle added a commit to dotty-staging/dotty that referenced this issue Apr 17, 2025
…ves ..

before skipping the parameter list, to disambiguate with subsequent clauses

Fixes scala#23011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant