Bug 11836 – UFCS doesn't overload methods

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-28T03:43:11Z
Last change time
2020-03-21T03:56:37Z
Assigned to
No Owner
Creator
Bloutiouf

Comments

Comment #0 by bloutiouf — 2013-12-28T03:43:11Z
Scenario: a class belongs to a library, and I don't want to change it. But for convenience I want to call methods with different arguments. Simple example: class C { void foo(int i) {} } void foo(C c, float f) { c.foo(cast(int)lrint(f)); } Sadly the following code doesn't compile: C c; c.foo(0f); Output: Error: function C.foo (int i) is not callable using argument types (float) It may be part of the definition of UFCS that the compiler only searches for global UFCSized functions when no such methods exist. If it's the case, it'd be great to extend this definition to searching for global functions only if no methods with the given arguments exist.
Comment #1 by b2.temp — 2016-10-19T21:09:07Z
*** This issue has been marked as a duplicate of issue 15830 ***