Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  78112   Status: Closed
TypeInfo() does not work with specialized generics types, even though type info has clearly been generated for these types
Project:  Delphi Build #:  14.0.3539.24502
Version:    14.0 Submitted By:   Thorsten Engler
Report Type:  Basic functionality failure Date Reported:  9/27/2009 1:37:02 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   273068
Resolution: Fixed (Resolution Comments) Resolved in Build: : 15.0.3841.32397
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 16
Description
None
Steps to Reproduce:
program Generics7;

{$APPTYPE CONSOLE}

uses
  RTTI;

type
  IGenInterface<T> = interface(IInvokable)
    function GenInterface: T;
  end;

  TGenRecord<T> = record
    GenRecord: string;
  end;

  TGenClass<T> = class
    GenClass: string;
  end;

  IGenInterfaceString = IGenInterface<string>;
  TGenRecordString = TGenRecord<string>;
  TGenClassString = TGenClass<string>;

  TContainer = record
    GenInterface: IGenInterfaceString;
    GenRecord: TGenRecordString;
    GenClass: TGenClassString;
  end;

var
  ctx: TRttiContext;

begin
  with ctx.GetType(TypeInfo(TContainer)).AsRecord do begin
    Assert(Length(GetFields) = 3);
    Assert(GetFields[0].FieldType.ToString = 'IGenInterface<System.string>');
    Assert(GetFields[1].FieldType.ToString = 'TGenRecord<System.string>');
    Assert(GetFields[2].FieldType.ToString = 'TGenClass<System.string>');
  end;

  //[DCC Error] Generics7.dpr(43): E2134 Type 'IGenInterfaceString' has no type info
  Assert(ctx.GetType(TypeInfo(IGenInterfaceString)).ToString = 'IGenInterface<System.string>');

  //[DCC Error] Generics7.dpr(46): E2134 Type 'TGenRecordString' has no type info
  Assert(ctx.GetType(TypeInfo(TGenRecordString)).ToString = 'TGenRecord<System.string>');

  //[DCC Error] Generics7.dpr(49): E2134 Type 'TGenClassString' has no type info
  Assert(ctx.GetType(TypeInfo(TGenClassString)).ToString = 'TGenClass<System.string>');
end.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01