position of using clause prevents overloaded extension method being picked
See original GitHub issueCompiler version
3.0.0-RC1
Minimized code and output
extension [T1](x: T1)(using Numeric[T1])
def combine[T2](y: T2)(using Numeric[T2]) = ???
def combine(y: String) = ???
val res = 100.combine(200)
// ^^^^^^^^^^^
// value combine is not a member of Int.
// An extension method was tried, but could not be fully constructed:
//
// combine() failed with
//
// value combine: <overloaded combine> does not take parameters
Expectation : should work, as when we move using
to the end of the parameter list:
extension [T1](x: T1)
def combine[T2](y: T2)(using Numeric[T2], Numeric[T1]) = ???
def combine(y: String) = ???
val res = 100.combine(200)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Why is my Extension Method overload not preferred? [duplicate]
This is pretty clear that an attempt is made to bind an extension method only if the overload resolution process fails to find...
Read more >Extension method call resolves to not-most-specific overload
By design, C# resolves overloads, including extension methods, primarily based on "namespace distance". Eric Lippert wrote an excellent blog ...
Read more >Extension Methods - C# Programming Guide - Microsoft Learn
Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the ...
Read more >All C# Extension Methods - ExtensionMethod.NET
I provided 2 overloads of this method. One of them accepts a separator and the other uses comma "," as default separator. Also...
Read more >2 CFR Part 200 -- Uniform Administrative Requirements, Cost ...
Disallowed costs means those charges to a Federal award that the Federal awarding agency or pass-through entity determines to be unallowable, in accordance ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What’s disturbing is that with non-extensions it succeeds:
So it seems we’re not far from the goal.
Also extension with overload, using: https://github.com/lampepfl/dotty/issues/13668