Martin Frb via fpc-devel <[email protected]> schrieb am Mo.,
24. Nov. 2025, 21:30:

> Normally, if I refer to a type then the first type found by the name
> will be taken => and if that type is not compatible, then I get an error.
> => See Example 2
>
> But, if I try to specialize a generic, and some other type by the same
> name exists, and comes first in the search order, then it will be ignored.
>
> The specialize below, ignores the "TFoo = class"  which can not be used,
> and finds the TFoo from unit1.
>
> Is that intended?
>

Yes, because in fact they don't have the same name. The name of a generic
with a single parameter is essentially "TFoo<>" while that of a generic
with two parameters is "TFoo<,>".

The amount of generic parameters is part of the type or routine name.

Note: non-Delphi modes currently don't allow type overloading in the same
unit, but it's on my ToDo-list to make it possible there as well, but it
requires some adjustments to allow compatibility to existing code which is
why it's not possible yet.

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to