Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  116682   Status: Closed
Interface delegation for generic interface generates wrong code
Project:  Delphi Build #:  XE, ... XE4
Version:    18.0 Submitted By:   Stefan Glienke
Report Type:  Basic functionality failure Date Reported:  6/19/2013 4:46:21 AM
Severity:    Critical / Show Stopper Last Updated: 9/12/2013 4:53:42 AM
Platform:    All versions Internal Tracking #:   40129
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE5
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Interface delegation for generic interface generates wrong code

Not being able to compile this code was fixed in XE (see QC #78189), but it generates wrong code.

Still an issue in XE2, XE3 and XE4.
Steps to Reproduce:
Expected: program executes correctly and prints "GetTest"
Actual: Access Violation

-------------
program Project1;
{$APPTYPE CONSOLE}
uses
  Classes, SysUtils;

type
  ITest<T> = interface
  end;

  TTest<T: class> = class(TInterfacedObject, ITest<T>)
    function GetTest: ITest<T>;
    property Test: ITest<T> read GetTest implements ITest<T>;
  end;

procedure Main;
var
  t: ITest<TPersistent>;
begin
  t := TTest<TPersistent>.Create;
end;

function TTest<T>.GetTest: ITest<T>;
begin
  Writeln('GetTest')
end;

begin
  try
    Main; // <<----- Access Violation
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;
end.
-------------
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01