-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ambiguous overload: false detection #16618
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 looks like the compiler tries to defer the inference of the type parameter of the first case class Foo[A](a: A) {
def bar(aa: A): Boolean = a == aa
def bar(that: Foo[A]) = a == that.a
}
object Test {
Foo[Int](123).bar(Foo(456))
Foo[Any](123).bar(Foo(456))
} |
Is this a bug or an intended effect? |
For me the current behaviour of the compiler is rather unexpected and misleading so I would classify this as a bug. |
The delay in instantiation is intended. It's one of the reasons Scala 3 generally infers better than Scala 2 (i.e. we are a couple of steps closer to global type inference). But in this case it has negative consequences. |
I haven't run the compiler through this, but running my brain through it, I think the only enhancement we could consider is adding a filter on the overloads consider by considering that |
I don't think that the added complexity would justify the gains. |
Compiler version
Scala 3.2.1
Minimized code
Output
The snippet compiles just fine on 2.12.17 and 2.13.9, but fails to compile on 3.2.1 with the following error:
However, if I change the
Test
object this way:then it compiles on 3.2.1 without any error as well.
Expectation
Both cases should compile on 3.2.1.
Notes
May be similar to #14582 and #16067.
The text was updated successfully, but these errors were encountered: