[fpc-pascal] Type used to specialize a generic

silvioprog silvioprog at gmail.com
Sat Nov 29 16:38:36 CET 2014

On Sun Nov 23 18:03:55 CET 2014, Joao Morais wrote:
> Hello list, is there a safe way to know the PTypeInfo, or at least the
> string literal of the type(s) used to specialize a generic? Eg:
>      TBarList = specialize TGenericList<TBar>
> On the sample above, starting with PTypeInfo of TBarList I know it was
> specialized using TBar type. I was using the following hack on 2.6.x:
>      VPos := Pos('$', AClassName);
>      if VPos > 0 then
>        VTypeName := Copy(AClassName, VPos + 1, Length(AClassName));
> ...which is broken on 2.7.

Unfortunatelly, no.

In Delphi, you can:

  TBar = class(TObject)

  TBarList = class(TList<TBar>)


Result: TList<Unit1.TBar> // so you can get the unit/type used between "<>"

But currently in FPC (tested from trunk):

{$mode delphi}

  TBar = class(TObject)

  TBarList = class(TFPGList<TBar>)


Result: TFPGList$1$crc07FFF574

Silvio Cl├ęcio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141129/312bbe2c/attachment.html>

More information about the fpc-pascal mailing list