Support for forward declarations of generic types
Original Reporter info from Mantis: trx
-
Reporter name: Svetozar Belic
Original Reporter info from Mantis: trx
- Reporter name: Svetozar Belic
Description:
The compiler currently does not support forward declarations of generic types such as:
TTest&LtPos;T> = class; // <- Not allowed.
TTest&LtPos;T> = class
end;
The attached patch file adds support for such declarations.
Additional information:
When a type section is parsed and a forward declaration of a generic type is encountered, a symbol and a definition (with oo_is_forward) is created as usual. Because it has oo_is_forward, this definition is incomplete.
Types which use the incomplete definition will add them self to its used_by list.
At the end of the type section (when the generic type is now parsed), resolve_forward_generic_types is called which goes through all the incomplete forward declarations, generates a specialization and replaces the incomplete definitions (by going through the incomplete definition's used_by list).
After it has been replaced, the incomplete definition is deleted.
If this is a wrong way to go about it, I would be happy if someone could provide some pointers to help me implement this a better way.
Mantis conversion info:
- Mantis ID: 34128
- Monitored by: » Boris (Boris Popov), » Artem3213212 (Artem3213212), » soerensen3 (soerensen3), » projekter (Benjamin Desef), » daniel_sap (Daniel Sapoundjiev), » @avagames (George), » @sergy.larin (Sergey Larin)