D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11836 - UFCS doesn't overload methods
Summary: UFCS doesn't overload methods
Status: RESOLVED DUPLICATE of issue 15830
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-28 03:43 UTC by Bloutiouf
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bloutiouf 2013-12-28 03:43:11 UTC
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 basile-z 2016-10-19 21:09:07 UTC

*** This issue has been marked as a duplicate of issue 15830 ***