Nested generic parameter types inside constraints compile in Delphi XE+ but not in FPC
Original Reporter info from Mantis: kyan
-
Reporter name: Constantine Yannakopoulos
Original Reporter info from Mantis: kyan
- Reporter name: Constantine Yannakopoulos
Description:
The following construct:
type
TConstraintClass<T> = class
end;
TGenericClass<T; U: TConstraintClass<T>> = class
end;
compiles in Delphi XE or later but in FPC it produces the error "Identifier not found 'T'" at the T generic parameter declaration in the constraint for U.
This construct allows the implementation of the Strategy/Policy pattern using generics (see attached example) so it would be nice if it worked in FPC.
Steps to reproduce:
Try to compile the attached example.
Additional information:
The attached example is a simplified case where this construct could be used in "real" code that actually does something. If it is too complicated please tell me to upload a simpler one.
Mantis conversion info:
- Mantis ID: 25678
- OS: Windows
- OS Build: Windows 7 x64
- Platform: Win32
- Version: 2.7.1
- Monitored by: » kyan (Constantine Yannakopoulos), » SDN (SDN), » etrusco (Flávio Etrusco), » BlackShark (BlackShark), » trx (Svetozar Belic), » @zamtmn (Andrey Zubarev), » daniel_sap (Daniel Sapoundjiev)