You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error message is quite confusing:
error: type mismatch;
found :
required: Int => String
val x: String = goo(foo _)
First of all, in this example it's quite simple to choose right 'foo' function.
However even overload resolution fails, error should be about overload resolution, not about "" type.
The text was updated successfully, but these errors were encountered:
@som-snytt said:
I guess that in the presence of an expected type pt, implicit search is failing and overload resolution doesn't get a chance.
The language in 7.3 is that if a view is found, is converted to v(e).
That implies: if no view is found, la-di-da.
For overload resolution, this is a value context and it should select the foo that is compatible with Int => String, where compatible means conforming after applying implicits.
But is the result different? The intuition here is that it should apply f to the result of foo, but I think this is still required:
implicit def f2(v: Int => Int): Int => String = { (x: Int) => f(x) }
If this were an application of foo(1) where a String is expected, it would supply the implicit f.
(In my previous comment, it infers Int. Disclaimer: my attention is divided by child care, and I'm just learning how all this works.)
@hubertp said:
Yes, that's correct. The implicit is not applied at all because typically in a non-overloaded scenario it would be applied during eta-expansion. In this case we don't even get to eta-expansion since we have to deal with overloading first and at that point the provided implicit is useless.
There is still a problem with the error message which I need to fix.
Error message is quite confusing:
error: type mismatch;
found :
required: Int => String
val x: String = goo(foo _)
First of all, in this example it's quite simple to choose right 'foo' function.
However even overload resolution fails, error should be about overload resolution, not about "" type.
The text was updated successfully, but these errors were encountered: