December 28, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11836

           Summary: UFCS doesn't overload methods
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bloutiouf@gmail.com


--- Comment #0 from Bloutiouf <bloutiouf@gmail.com> 2013-12-28 03:43:11 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------