[Issue 11836] New: UFCS doesn't overload methods

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 28 03:43:14 PST 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 at puremagic.com
        ReportedBy: bloutiouf at gmail.com


--- Comment #0 from Bloutiouf <bloutiouf at 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: -------


More information about the Digitalmars-d-bugs mailing list