Skip to content

Struct with two or more bases will have duplicate member names #592

@2A5F

Description

@2A5F

#367 partially solves the problem, but pure virtual classes will still be generated duplicate

struct Foo
{
    virtual ~Foo() = default;
};

struct Bar
{
    virtual ~Bar() = default;
};

struct Baz: Foo, Bar
{
};

output:

public unsafe partial struct Foo : Foo.Interface
{
    public void** lpVtbl;
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Foo*, void>)(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this));
    }
    public interface Interface
    {
        void Dispose();
    }
}

public unsafe partial struct Bar : Bar.Interface
{
    public void** lpVtbl;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Bar*, void>)(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this));
    }
    public interface Interface
    {
        void Dispose();
    }
}

public unsafe partial struct Baz : Baz.Interface
{
    public void** lpVtbl;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Baz*, void>)(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this));
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        ((delegate* unmanaged[Thiscall]<Baz*, void>)(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this));
    }
    public interface Interface : Foo.Interface, Bar.Interface
    {
    }
}

This is wrong. There should be multiple virtual table pointers when multiple inheritance occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions