Can a generic Delphi class derive from its class argument?


I've been trying to define a generic, inheritable TSingleton class. Here's what I had in progress:

  TSingleton<RealClass, InheritsFrom : class> = class(InheritsFrom)
  strict private
    class var FInstance : RealClass;
    procedure InstanceInitialization;virtual;
    destructor Destroy; override;
    class procedure Create; reintroduce;
    class function Instance : RealClass;
    class procedure InstanceFree;

The goal was to be able to "insert" the singleton pattern in an inheritance tree. so instead of declaring something like this :

  TMySingletonComponent = class(TComponent)


And need to implement the singleton pattern there, I would declare something like this :

  TMyGenericSingletonComponent = class(TSingleton<TMyGenericSingletonComponent,TComponent>)

Sadly, this won't work. I'm getting the following error(In D2010):

  TSingleton<RealClass, InheritsFrom : class> = class(InheritsFrom) ///E2021 Class type required

Now I was wondering, would this work in Delphi XE? Is there some "clean hack" I could use to make this work in D2010? Is there some fundamental reasons why this can't work?

By design, you can't create a generic class which derives from one of its type arguments.