<div dir="ltr"><div>Hello,</div><div><br></div><div>I'm trying to port a Delphi code to FPC, and it has a structure like:</div><div><br></div><div><div>  TType = class(TObject)</div><div>  end;</div><div><br></div><div>  TTest<T1; T2: TType> = class(TObject)</div><div>  end;</div><div><br></div><div>  TFoo = class(TType)</div><div>  end;</div><div><br></div><div>  TBar = class(TTest<string, TFoo>)</div><div>  end;</div></div><div><br></div><div>I.e., T1 accepts any type, but T2 accepts _only_ TType and/or their descendants.<br></div><div><br></div><div>I tried the following code in FPC:</div><div><br></div><div><div>  TType = class(TObject)</div><div>  end;</div><div><br></div><div>  generic TTest<T1; T2: TType> = class(TObject)</div><div>  end;</div><div><br></div><div>  TFoo = class(TType)</div><div>  end;</div><div><br></div><div>  TBar = class(specialize TTest<string, TFoo>)</div><div>  end;</div></div><div><br></div><div>But:</div><div><br></div><div>===</div><div><div>Compile Project, Target: project1.exe: Exit code 1, Errors: 2</div><div>Unit1.pas(30,34) Error: class type expected, but got "AnsiString"</div><div>Unit1.pas(30,47) Error: class type expected, but got "<erroneous type>"</div></div><div><div>===<br></div><div><br></div><div>If I declare "T2" instead of "T2: TType", it compiles, but using this declaration, a programmer can use accidentally a non descendant type of TType.</div><div><br></div><div>Is there an issue about this in bugtracker?</div><div><br></div><div>Thank you!</div><div><br></div>-- <br><div>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>