-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
position of using clause prevents overloaded extension method being picked #11713
Comments
That will be quite hard to do. Overloading resolution is super hard as it is. This would make it worse. |
Is its interaction with implicit resolution documented somewhere? |
What's disturbing is that with non-extensions it succeeds: def combine[T1,T2](x: T1)(using Numeric[T1])(y: T2)(using Numeric[T2]) = ???
def combine[T1](x: T1)(using Numeric[T1])(y: String) = ???
val res = combine(100)(200) So it seems we're not far from the goal. |
Answering to myself : https://dotty.epfl.ch/docs/reference/changed-features/implicit-resolution.html
It says nothing about the position of argument lists, probably because it predates multiple implicit argument lists, and the fact that these had to be at the end(?) |
I think I found a similar occurrence: extension [T1] (x: T1)
def f(fn: T1 ?=> Unit) =
fn(using x)
def f(s: String) =
s
// just yields "Hello"
val a = 100.f("Hello")
// error, 100.f() was considered yada yada
val res = 100.f {
println("wat")
} I am guessing that is because |
Also extension with overload, using: #13668 |
In some cases while going deeper into alternatives during overload resolution, we may end up with a nested polytype after dropping contextual parameters. In particular this can happen for an extension with a `using` clause, as seen in tests/pos/i11713.scala and tests/pos/i13668.scala. The overload applicability test fails here unless the type parameter lists are merged. Co-authored-by: Gagandeep Kalra <[email protected]> Co-authored-by: Mark T. Kennedy <[email protected]> Fixes scala#11713 Fixes scala#13668
Compiler version
3.0.0-RC1
Minimized code and output
Expectation : should work, as when we move
using
to the end of the parameter list:The text was updated successfully, but these errors were encountered: