* Allow System.Variants (Delphi-compatible name) to be found when inserting variants unit

This commit is contained in:
Michael VAN CANNEYT 2023-03-06 18:44:45 +01:00
parent b31bf50369
commit a8ee66823a

View File

@ -211,23 +211,30 @@ implementation
procedure maybeloadvariantsunit;
var
hp : tmodule;
addsystemnamespace : Boolean;
begin
{ Do we need the variants unit? Skip this
for VarUtils unit for bootstrapping }
if not(mf_uses_variants in current_module.moduleflags) or
(current_module.modulename^='VARUTILS') then
(current_module.modulename^='VARUTILS') or
(current_module.modulename^='SYSTEM.VARUTILS') then
exit;
{ Variants unit already loaded? }
hp:=tmodule(loaded_units.first);
while assigned(hp) do
begin
if hp.modulename^='VARIANTS' then
if (hp.modulename^='VARIANTS') or (hp.modulename^='SYSTEM.VARIANTS') then
exit;
hp:=tmodule(hp.next);
end;
{ Variants unit is not loaded yet, load it now }
Message(parser_w_implicit_uses_of_variants_unit);
addsystemnamespace:=namespacelist.Find('System')=Nil;
if addsystemnamespace then
namespacelist.concat('System');
AddUnit('variants');
if addsystemnamespace then
namespacelist.Remove('System');
end;