Ok, {$modeswitch advancedrecords} was the essential thing. Now it compiles and I get the same error from codetools.
I must detach myself. I don't know how to fix this one.
[Edit]
The syntax is strange. Why does FPC accept it? There are 2 nested "specialize" clauses but the inner one "specialize TVI&LtPos;T>" does not really specialize anything. It still has the "T" there.
Maybe I just don't understand generics enough...
generic TVISet&LtPos;T> = class(specialize TheBTreeSet&LtPos;specialize TVI&LtPos;T>>); @juha Manninen
if you specialized the generic above the nested generic is also specialized and resolves to this:
specialize TVISet< Integer >;
resolves to
class(specialize TheBTreeSet&LtPos;specialize TVI&LtPos;Integer>>);
I think the error is in PascalParserTool somewhere in lines 6070+, after checking for unit name.
Maybe it needs to check for '<' after the identifier or specialize keyword as first identifier (depending on mode delphi or objfpc). There it might be necessary to recursively call TPascalParserTool.ReadSpecialize again. Sorry I don't understand CodeTools enough to make the change myself.
Please note that in mode objfpc the optional unit identifier comes before the specialize keyword.
In Mode Delphi the nested specialization goes like this:
type TypeName = UnitNameCanBeDotted.TypeName < UnitNameCanBeDotted.TypeName < UnitNameCanBeDotted.TypeName >>;
In Mode Objfpc the equivalent would be:
type TypeName = UnitNameCanBeDotted. specialize TypeName < UnitNameCanBeDotted. specialize TypeName < UnitNameCanBeDotted.TypeName >>;
I would be very happy if this was fixed! Thanks in advance!
Yes the patch fixes the issue and does not break anything. I applied it.
Thank you soerensen3! I guess you studied the Codetools for a while.
Notes about patches for the future:
Please remove old code instead of commenting it out. Old code can be found in commit history if needed.
I removed it before the commit. The code became shorter and simpler. Good!
There was a 16 lines offset. I guess you used the released Lazarus version instead of trunk. Sometimes it can cause a conflict and a patch cannot be applied, thus trunk is recommended for all development.
$ cd components/codetools/
$ patch -p0 < ~/patch/fix-nested-generics-specialization.patch
patching file pascalparsertool.pas
Hunk # 1 succeeded at 6068 (offset 16 lines).
Hunk # 2 succeeded at 6085 (offset 16 lines).
I think the patch is okay but other parts of codetools still rely on only getting identifiers as generic parameters.
I'll have a look and try to update those parts to get them working again.