0

I am using Delphi 10.4 (untested for D11).

I am trying to extend a function in an existing class with a ClassHelper so that the function becomes a virtual function. The compilation works partially.

  TMetaTable = class
  public
    function Clone: TMetaTable;
  end;

  TMetaTableHelper = Class helper for TMetaTable
  public
    function Clone: TMetaTable; virtual;
  End;
  
identifierName = class|record helper [(ancestor list)] for TypeIdentifierName 
// [(ancestor list)] can I do some magic here like add additional support for 
//TVirtualInterface or IInterface?
 memberList
end;

The error message is:

[dcc32 Error] MbfXData.MetaTable.pas(73): E2291 Missing implementation of interface method IInterface.QueryInterface 
[dcc32 Error] MbfXData.MetaTable.pas(73): E2291 Missing implementation of interface method IInterface._AddRef 
[dcc32 Error] MbfXData.MetaTable.pas(73): E2291 Missing implementation of interface method IInterface._Release

Does anyone know how to create a virtual method in a ClassHelper? Do I need to include a definition of TVirtualInterface in the ClassHelper?

I can't find any documentation on how to use multiple ancestors. And I found some (perhaps older Delphi versions) answers stating its impossible. But to me it looks just like I am missing to add the Virtual Managing Elements.

If it's impossible: can you guide me to a followup read so I can understand how to look at Delphi's build in RTTI funtions to determine it's impossible.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 2
    Despite the syntax, Delphi class helpers don't actually support ancestors. Also, you can't add virtual methods to a class via a class helper, see https://stackoverflow.com/a/55144429/65863 – Remy Lebeau Dec 16 '22 at 15:46

0 Answers0