Skip to content

Python override of an inherited pure virtual operator() is not generated #146

Open

Description

@vgvassilev

Observed with cppyy 3.5.0 (cppyy-cling 6.32.8) and cppjit 0.1.0a1 alike on 2026-10-08; the same
Python class shape works when the pure virtual has a plain name. Not cppjit-specific.

import cppyy   # or cppjit; identical result
cppyy.cppdef(r'''
struct Impl { virtual ~Impl() {} virtual void operator()(int*) = 0; virtual void operator()() = 0;
              virtual Impl* Clone() = 0; virtual bool IsStandalone() = 0; };
struct Standalone : Impl { void operator()(int*) override {} bool IsStandalone() override { return true; } };
struct NamedImpl { virtual ~NamedImpl() {} virtual void run() = 0; virtual void other() = 0; };
struct NamedMid : NamedImpl { void other() override {} };
''')
# works: a pure virtual with a plain name, inherited through an abstract intermediate class
type("A", (cppyy.gbl.NamedMid,), {"run": lambda self: None})()
# works: both operator() overloads pure in the direct base
# fails: pure operator()() inherited through Standalone, which implements the other overload
type("B", (cppyy.gbl.Standalone,), {"operator()": lambda self, *a: None, "Clone": lambda self: self})()
# TypeError: cannot instantiate abstract class '__cppyy_internal::Dispatcher1'

Notes: the override must be registered under the C++ spelling "operator()" (a __call__ method
is not matched); that part is convention, not the defect. The defect is that the generated
dispatcher does not override the inherited pure operator()() when the intermediate base already
overrides operator()(int*), so the dispatcher class stays abstract. BioDynaMo's
StandaloneOperationImpl has exactly this shape. Workaround in act3/cartopiax_session.py: a
four-line C++ adapter that spells the pure virtual as Run().

Activity

  1. added a commit that references this issue on Oct 14, 2026
    817bfe5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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