Generics: Error: Class type expected, but got "T"
Original Reporter info from Mantis: silvioprog
-
Reporter name: silvioprog
Original Reporter info from Mantis: silvioprog
- Reporter name: silvioprog
Description:
Hi.
Consider the following test:
program Project1;
{$MODE DELPHI}
uses Classes;
type
TFoo<T: TPersistent> = class(TPersistent)
end;
TBar = class(TPersistent)
public
function Test<T: TPersistent>: TFoo<T>;
end;
function TBar.Test<T>: TFoo<T>;
begin
Result := nil;
end;
begin
end.
On Delphi, it compiles fine, however, on FPC, I've got the following problem:
Compile Project, Target: project1: Exit code 1, Errors: 3
project1.lpr(16,29) Error: Class type expected, but got "T"
project1.lpr(16,15) Error: Function header doesn't match any method of this class "Test$1:<erroneous type>;"
project1.lpr(13,14) Error: Found declaration: Test$1:TFoo$1<PROJECT1.TBar.Test$1T>;
Is this a bug, or some special switch missing in the example?
Thank you!
Mantis conversion info:
- Mantis ID: 35943
- Version: 3.3.1
- Monitored by: » Akira1364 (Akira1364)
Edited by Sven/Sarah Barth