On 03/02/2026 16:58, Hairy Pixels via fpc-devel wrote:
On Feb 3, 2026 at 10:42:05 PM, Martin Frb via fpc-devel
<[email protected]> wrote:
https://gitlab.com/freepascal.org/fpc/source/-/issues/41604
program Project1;
{$Mode objfpc}
{$Interfaces CORBA}
type
IFoo = interface end;
TBar = class(TObject, IFoo) end;
generic MyGen<A: IFoo> = class end;
TSome = specialize MyGen<TBar>;
begin
end.
ok so I can see the whole thing now and this should compile. TBar
implements IFoo and "A" must conform to IFoo so TBar is compatible
with "A".
Not really.
Below stops compiling, when you uncomment the specialize.
IFoo has a method Test.
TBar does not have that. Only TBar as IFoo would have it. But it isn't
cast to IFoo.
program Project1;
{$Mode objfpc}
{$Interfaces CORBA}
type
IFoo = interface
procedure Test;
end;
TBar = class(TObject, IFoo)
procedure BarTest; virtual; abstract;
procedure IFoo.Test = BarTest;
end;
generic MyGen<A: IFoo> = class
procedure p1(x: A);
end;
//TSome = specialize MyGen<TBar>;
procedure MyGen.p1(x: A);
begin
x.Test
end;
begin
end._______________________________________________
fpc-devel maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel