www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5884] New: Cannot use function named 'init' with class subtyping

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5884

           Summary: Cannot use function named 'init' with class subtyping
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



15:10:26 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5884


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5884




15:11:56 PDT ---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5884


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



15:15:48 PDT ---
Ok I'm closing this down. I'll just define an "initialize" method which
redirects to the COM's init method.

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