Bug 5884 – Cannot use function named 'init' with class subtyping
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-04-24T15:10:00Z
Last change time
2011-04-24T15:15:48Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2011-04-24T15:10:26Z
class Foo
{
public:
void savestate() { }
void loadstate(void*) { }
void init2(void*) { }
void init(void*) { }
}
class Bar
{
private Foo _foo;
alias _foo this;
this()
{
_foo = new Foo;
}
}
void main()
{
auto b = new Bar;
b.savestate(); // ok
b.loadstate(null); // ok
b.init2(null); // ok
b.init(null); // Error: no property 'opCall' for type 'test.Foo'
}
It's a blocker for me because I have a COM interface with a method called "init", and I'm unable to use subtyping in a class that holds a COM object due to this weird bug.
Comment #1 by andrej.mitrovich — 2011-04-24T15:11:56Z
Now I remembered that objects have an .init property. Crap.. so this might not be a bug after all.
How would I work around this?
Comment #2 by andrej.mitrovich — 2011-04-24T15:15:48Z
Ok I'm closing this down. I'll just define an "initialize" method which redirects to the COM's init method.