fpc/tests/test/tgeneric116.pp
Frederic Kehrein 05b73f1523 Postponing building of VMT until inheritance chain is specialized
This commit does 3 changes:
1. Introduce new option `oo_inherits_not_specialized` indicating if
   somewhere in the inheritance chain of an object there is a non
   specialized generic parameter
2. Avoid building the VMT for an object which has a generic parameter in
   the inheritance chain (fixes )
3. When no vmt is build `insert_struct_hidden_paras` usually called as
   part of `build_vmt` will be called seperately to add missing
   parameters
2024-12-08 17:54:50 +00:00

31 lines
432 B
ObjectPascal

{$Mode ObjFPC}{$H+}
type
TBase = class
public
function Foo:Integer;virtual;abstract;
end;
generic TTest<T:class> = class(T)
public
end;
generic TTest2<T:class> = class(specialize TTest<T>)
public
function Foo:Integer;override;
end;
function TTest2.Foo:Integer;
begin
Result:=42;
end;
var
b: TBase;
begin
b:=specialize TTest2<TBase>.Create;
if b.Foo<>42 then
Halt(1);
WriteLn('Ok');
end.