"leledumbo" wrote 18 lines
This code:
{$mode objfpc}{$H+}
type
generic TType1<A,B> = class end;
generic TType2 = specialize TType1<A,String>;
begin
end.
fails:
x.pas(5,42) Error: Identifier not found "A"
x.pas(5,42) Error: Type identifier expected
x.pas(5,50) Error: Illegal expression
x.pas(7,1) Error: This type can't be a generic
As the compiler tells you: A is not a defined type. The compiler needs to know the complete type before it can use any type defined in there and in this case the full type is "TType1<A, String>" where both types must come from outside the type.
Show quoted text 13 lines
but this code:
{$mode objfpc}{$H+}
type
generic TType1<A,B> = class end;
generic TType2 = class(specialize TType1<A,String>) end;
begin
end.
works. Does it have to be like the 2nd code for partial generic
specialization?
This must only work if you write "generic TType2<A> =...". Otherwise this is a bug.
One can argue however that the following should be valid as well (AFAIK it is not currently):
=== example begin ===
type
generic TType2<A> = specialize TType1<A, String>;
=== example end ===
Regards,
Sven