wlav / cppyy

Other
384 stars 38 forks source link

using Parent::method while overriding all overloads prevents access to any further methods #204

Open N-Coder opened 7 months ago

N-Coder commented 7 months ago

The following code:

import cppyy

cppyy.cppexec("""
class Base {
public:
    Base() {};
    virtual void foo(int v) = 0;
    void baz() {};
};
class Mid : public Base {
public:
    Mid() {};
    virtual void foo(int v) override = 0;
    virtual void foo(float v) { };
};
class Derived : public Mid {
public:
    Derived() {};
    using Base::foo; // comment this line out to fix
    virtual void foo(int v) override {};
    virtual void foo(float v) override {};
    void bar() {};
};
""")

obj = cppyy.gbl.Derived()
obj.baz()
obj.foo(5)
obj.bar()

yields

AttributeError: 'Derived' object has no attribute 'bar'

All methods that come after the superfluous using seem to be ignored, while commenting out the using seems to fix the issue. I'm not aware of this being something a compiler would complain about (the code compiles fine with clang++-17 -Wall).