The empty class would stay empty...
Ok while writing the dummy code, it wont work as I thought... I tried some amendments
dummy code
interface
type
TOtherClassPlaceHolder = record // advanced / so you can have type helpers
Value: TObject; // can hold the real other class
end;
TFoo = class
private
FOther: TOtherClassPlaceHolder; // can be made to work
public
procedure DoFoo(o: TOtherClassPlaceHolder); // will not work / can not be called with the other class
end;
implementation
uses other;
type
// helper defined nested in generic class, so it can be specialized... not tested if that works.
// if not the helper must be implemented here (and in every unit....) :(
TOtherClassHelper = specialize other.TClassContainingHelperFromOtherUnit<TOtherClassPlaceHolder>.TheHelper;
// not sure if that works for record, or must be in the record, or can go into the typehelper.
operator := (o: TRealOtherClass): TOtherClassPlaceHolder;
begin
result.value := o;
end;
procedure TFoo.
begin
Fother.DoSomething {Other}; // goes via the helper. The helper will do: TRealOtherClass(Value).DoSomethnig;
end;
The unit with the real other class then defines a generic
generic TClassContainingHelperFromOtherUnit<A:class> = class
public type
TheHelper = type helper for A
procedure DoSomething
end;
end;
I haven't tested if you can do that nested helper declaration...
And as I said, its not complete.
You can't call "DoFoo" from outside, because the custom operator wont be there, and the types wont be compatible without.
It might no be worth it...
But if all of it is auto generated, and the above actually can be compiled (again not tested), then it takes maybe half of the issues away? and no wait for anything...
You can get the function call param... but then you need a 3rd unit for an empty base class, so "the real other" actually inherits from the empty base class (on mess with lots of abstract / empty class instead).
And the type helper add all the methods to the empty class.