-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ambiguously overloaded methods fail to error when assigned to a val #18294
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
Comments
I'll try to look at it, but I have a few questions: Why should it produce an ambiguous overload error ? We want to assign to Also, if both "direct" & "indirect" calls must fail, shouldn't we instead prevent people from defining 2 methods where the second returns a |
It's "b" in Scala 2. I think this issue was previously discussed for Dotty, but I don't have a link or explanation handy. (Maybe in Scala 2, overload resolution precedes eta expansion; that is, it's not an application, so first take alternatives that are compatible with the expected type; but the definition of compatible says after eta expansion, so that idea is not right.) |
It's a little ironic how your logical steps lead you to the other answer than what the compiler does - perhaps good evidence that it should be made to error as ambiguous. Not that we could afford to just flip the meaning from one version to the next anyways... At a guess, the requirement of |
Seems legit 😆 |
This is a "direct use" of
Spec says:
None of those conditions apply. Odersky is firm in the linked PR that the behavior is "as specified". Maybe these are the spec words which mean "do the obvious thing and take |
Duplicates #4831 Dotty came around and agrees with Scala 2 since [checks watch] 3.3.4.
I see this behavior progressed in the linked PR for 3.4.1 then backported to LTS. |
Compiler version
main (97677cc), 3.3.0 and likely any previous version
Minimized code
Output
Compiles, and when run prints "a".
Expectation
Should error out with an Ambiguous Overload error, like using
f
directly does.Additional comment
I found this when working on #18286, and I know that
resolveOverloaded1
method here can affect whichf
is being chosen - so the issue likely lies somewhere there.The text was updated successfully, but these errors were encountered: