Delphi is fine
In FPC the code above gives an error like yours, but in Delphi everything is OK
But this original code adapted for Delphi compiles successfully in Delphi as well
Please note that
Okoba's code uses
record and
not class. In that case the code won't compile in Delphi either.
It seems to be a compiler bug
While there is a bug regarding this, in the end it is very likely that it will not work
anyway, because if
T in
TTest1<> is used as a field the code will fail due to
TTest2<> not being completely defined at the point of specialization inside
TTest2<>. Generics can not be used to circumvent the need of proper declaration order.
@Okoba
Like this ?
Please compare your code to what
Okoba wants. They lead to different behavior (assuming
Okoba's code would work).