-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Overloading doesn't work with function types #7792
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
Not sure if that's a real issue since we are working with untyped trees of arguments on overload resolution time, so we may not have a way to precisely resolve the type of |
Though it works with trait Foo {
def g(f: Int => Int): Int = 1
def g(f: Int => String): String = "2"
} (Second |
I think that's precisely where Scala 2 and Dotty differ when dealing with overloaded functions taking lambda arguments. The Dotty version is simpler but also a bit more restrictive. We need to decide what the right spec is. |
Handling this kind of situation was added in Scala 2.13, because the new Scala collections basically rely on this working. They use overloading much more, whereas previously things were handled with complicated |
I don't think we will change this, after all. |
minimized code
It works in Scala 2. If you explicitly specify the type of the lambda argument,
m.g((x: Int) => 1)
, it also works.expectation
The code should correctly resolve the overload alternative.
The text was updated successfully, but these errors were encountered: