Bug 1646 – method overloaded on delegate and function matches both in certain cases
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2007-11-07T14:41:00Z
Last change time
2015-06-09T01:14:21Z
Keywords
accepts-invalid, rejects-valid
Assigned to
bugzilla
Creator
schveiguy
Comments
Comment #0 by schveiguy — 2007-11-07T14:41:59Z
The following code produces the issue:
class A
{
void f1(void delegate() dg)
{
}
void f1(void function() dg)
{
}
}
class C
{
this()
{
A a = new A;
a.f1(&x);
}
void x()
{
}
}
The call to f1 should only match the delegate version because x requires a context pointer. This was the behavior on D 1.0.
A workaround exists, if you change the line to:
a.f1(&this.x);
Comment #1 by schveiguy — 2008-07-10T12:48:08Z
This issue appears to be fixed in D 2.015 and 2.016