From d58721b15ce6b25a558eb3a18d898b7d995faf32 Mon Sep 17 00:00:00 2001 From: Partouf Date: Thu, 8 Oct 2026 18:11:20 +0200 Subject: [PATCH] Use System.Generics.* when FPC's RTL has dotted unit names An FPC built with dotted unit names (FPC_DOTTEDUNITS, as in FPC trunk's namespaced RTL) ships System.Generics.Collections and no unit called Generics.Collections, so DelphiAST does not compile against it as-is. Reaching the undotted name through a unit scope (-FNSystem) is not enough either: a generic specialised in two units that each found Generics.Collections that way comes out as two incompatible types, e.g. DelphiAST.pas(726,67) Error: Incompatible type for arg no. 2: Got "TList", expected "TLIST" Follow the convention the dotted RTL itself uses and name the dotted unit under {$IFDEF FPC_DOTTEDUNITS}. Nothing defines that for user code, so a dotted build passes -dFPC_DOTTEDUNITS; Delphi and an undotted FPC see exactly the uses clauses they saw before. Co-Authored-By: Claude Opus 5.5 --- Source/DelphiAST.Classes.pas | 2 +- Source/DelphiAST.ProjectIndexer.pas | 7 ++++++- Source/DelphiAST.Serialize.Binary.pas | 2 +- Source/DelphiAST.SimpleParserEx.pas | 2 +- Source/DelphiAST.Writer.pas | 2 +- Source/DelphiAST.pas | 2 +- Source/SimpleParser/SimpleParser.Lexer.pas | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/DelphiAST.Classes.pas b/Source/DelphiAST.Classes.pas index 869d614e..a03af081 100644 --- a/Source/DelphiAST.Classes.pas +++ b/Source/DelphiAST.Classes.pas @@ -5,7 +5,7 @@ interface uses - SysUtils, Generics.Collections, SimpleParser.Lexer.Types, DelphiAST.Consts; + SysUtils, {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, SimpleParser.Lexer.Types, DelphiAST.Consts; type EParserException = class(Exception) diff --git a/Source/DelphiAST.ProjectIndexer.pas b/Source/DelphiAST.ProjectIndexer.pas index 77e217aa..46559088 100644 --- a/Source/DelphiAST.ProjectIndexer.pas +++ b/Source/DelphiAST.ProjectIndexer.pas @@ -5,7 +5,12 @@ interface uses - Classes, Generics.Defaults, Generics.Collections, + Classes, + {$IFDEF FPC_DOTTEDUNITS} + System.Generics.Defaults, System.Generics.Collections, + {$ELSE} + Generics.Defaults, Generics.Collections, + {$ENDIF} SimpleParser.Lexer.Types, DelphiAST, DelphiAST.Classes, DelphiAST.Consts; diff --git a/Source/DelphiAST.Serialize.Binary.pas b/Source/DelphiAST.Serialize.Binary.pas index 04ac2834..f4a820ee 100644 --- a/Source/DelphiAST.Serialize.Binary.pas +++ b/Source/DelphiAST.Serialize.Binary.pas @@ -6,7 +6,7 @@ interface uses Classes, - Generics.Collections, + {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, DelphiAST.Consts, DelphiAST.Classes; diff --git a/Source/DelphiAST.SimpleParserEx.pas b/Source/DelphiAST.SimpleParserEx.pas index 6afd7105..6f015b2e 100644 --- a/Source/DelphiAST.SimpleParserEx.pas +++ b/Source/DelphiAST.SimpleParserEx.pas @@ -3,7 +3,7 @@ interface uses - SysUtils, Generics.Collections, SimpleParser, SimpleParser.Lexer.Types, + SysUtils, {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, SimpleParser, SimpleParser.Lexer.Types, SimpleParser.Lexer, Classes; type diff --git a/Source/DelphiAST.Writer.pas b/Source/DelphiAST.Writer.pas index e85b06ec..d98fda2b 100644 --- a/Source/DelphiAST.Writer.pas +++ b/Source/DelphiAST.Writer.pas @@ -26,7 +26,7 @@ TSyntaxTreeWriter = class implementation uses - Generics.Collections, + {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, {$IFNDEF FPC} DelphiAST.Serialize.Binary, {$ENDIF} diff --git a/Source/DelphiAST.pas b/Source/DelphiAST.pas index 0b79f428..b8129355 100644 --- a/Source/DelphiAST.pas +++ b/Source/DelphiAST.pas @@ -5,7 +5,7 @@ interface uses - SysUtils, Classes, Generics.Collections, SimpleParser, SimpleParser.Lexer, + SysUtils, Classes, {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, SimpleParser, SimpleParser.Lexer, SimpleParser.Lexer.Types, DelphiAST.Classes, DelphiAST.Consts, DelphiAST.SimpleParserEx; type diff --git a/Source/SimpleParser/SimpleParser.Lexer.pas b/Source/SimpleParser/SimpleParser.Lexer.pas index ef8428ff..22577856 100644 --- a/Source/SimpleParser/SimpleParser.Lexer.pas +++ b/Source/SimpleParser/SimpleParser.Lexer.pas @@ -56,7 +56,7 @@ interface uses SysUtils, Classes, Character, {$IFDEF FPC} - Generics.Collections, + {$IFDEF FPC_DOTTEDUNITS}System.Generics.Collections{$ELSE}Generics.Collections{$ENDIF}, {$ENDIF} SimpleParser.Lexer.Types;