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

This commit is contained in:
Michaël Van Canneyt 2023-03-06 18:44:45 +01:00
parent a9cc89ff46
commit 9e228ff355

View File

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