Rtti不适用于用作类字段的泛型类型

iam*_*osy 7 delphi rtti delphi-xe

我在使用rtti获取有关泛型类字段的信息时遇到了问题.经过一段时间的谷歌搜索后,我在QC中找到了一个描述该问题的条目.我的问题是,如果有人知道一个解决方法,或者这是否修复了Delphi XE2.以下是来自QC的重复该错误的源代码片段.

program Generics;

    {$APPTYPE CONSOLE}

    uses
       Generics.Collections, Rtti, SysUtils;

    type
       TIntList = TList<Integer>;

       TRecContainer = record
         FList: TIntList;
       end;

       TObjContainer = class
         FList: TIntList;
       end;

    var
       ctx: TRttiContext;
       f: TRttiField;

    begin
       ctx := TRttiContext.Create;
       try
         for f in ctx.GetType(TypeInfo(TRecContainer)).GetFields do
           if f.FieldType <> nil then
             writeln(f.FieldType.Name)
           else
             writeln('f.FieldType = nil');
         for f in ctx.GetType(TypeInfo(TObjContainer)).GetFields do
           if f.FieldType <> nil then
             writeln(f.FieldType.Name)
           else
             writeln('f.FieldType = nil');
       finally
         ctx.Free;
         readln;
       end;
    end.
Run Code Online (Sandbox Code Playgroud)

RRU*_*RUZ 8

遗憾的是,这个错误仍然存​​在于Delphi XE2中,因为您可以声明TIntList类似的类型

TIntList = class(TList<Integer>);
Run Code Online (Sandbox Code Playgroud)