fcl-passrc: fixed unit implementation uses namespace as unit intf identifier

git-svn-id: trunk@46751 -
This commit is contained in:
Mattias Gaertner 2020-09-02 20:23:27 +00:00
parent 545ee82ec4
commit dd82f63c3f
2 changed files with 36 additions and 6 deletions

View File

@ -5672,17 +5672,21 @@ begin
ParentScope:=Scopes[ScopeCount-2]; ParentScope:=Scopes[ScopeCount-2];
if ParentScope is TPasSectionScope then if ParentScope is TPasSectionScope then
begin begin
// check unit interface and implementation duplicates
OlderIdentifier:=TPasSectionScope(ParentScope).FindLocalIdentifier(aName); OlderIdentifier:=TPasSectionScope(ParentScope).FindLocalIdentifier(aName);
if IsGeneric then repeat
OlderIdentifier:=SkipGenericTypes(OlderIdentifier,TypeParamCnt); if IsGeneric then
if OlderIdentifier<>nil then OlderIdentifier:=SkipGenericTypes(OlderIdentifier,TypeParamCnt);
begin if OlderIdentifier=nil then break;
OlderEl:=OlderIdentifier.Element; OlderEl:=OlderIdentifier.Element;
if (Identifier.Kind=pikSimple) if (Identifier.Kind=pikNamespace)
or (OlderIdentifier.Kind=pikNamespace) then
else if (Identifier.Kind=pikSimple)
or (OlderIdentifier.Kind=pikSimple) then or (OlderIdentifier.Kind=pikSimple) then
RaiseMsg(20190818141630,nDuplicateIdentifier,sDuplicateIdentifier, RaiseMsg(20190818141630,nDuplicateIdentifier,sDuplicateIdentifier,
[aName,GetElementSourcePosStr(OlderEl)],El); [aName,GetElementSourcePosStr(OlderEl)],El);
end; OlderIdentifier:=OlderIdentifier.NextSameIdentifier;
until OlderIdentifier=nil;
end; end;
end; end;

View File

@ -373,6 +373,7 @@ type
Procedure TestUnit_DottedPrg; Procedure TestUnit_DottedPrg;
Procedure TestUnit_DottedUnit; Procedure TestUnit_DottedUnit;
Procedure TestUnit_DottedExpr; Procedure TestUnit_DottedExpr;
Procedure TestUnit_DottedSystem;
Procedure TestUnit_DuplicateDottedUsesFail; Procedure TestUnit_DuplicateDottedUsesFail;
Procedure TestUnit_DuplicateUsesDiffName; Procedure TestUnit_DuplicateUsesDiffName;
Procedure TestUnit_Unit1DotUnit2Fail; Procedure TestUnit_Unit1DotUnit2Fail;
@ -5975,6 +5976,31 @@ begin
ParseProgram; ParseProgram;
end; end;
procedure TTestResolver.TestUnit_DottedSystem;
begin
AddModuleWithIntfImplSrc('System.SysUtils.pas',
LinesToStr([
'type TFlag = word;'
]),
''
);
AddModuleWithIntfImplSrc('UnitA.pas',
LinesToStr([
''
]),
LinesToStr([
'uses System.SysUtils;',
'type TSize = TFlag;',
'type TWidth = System.SysUtils.TFlag;',
'type TBird = System.integer;',
'type TEagle = integer;',
'']) );
StartProgram(true);
Add('uses UnitA;');
Add('begin');
ParseProgram;
end;
procedure TTestResolver.TestUnit_DuplicateDottedUsesFail; procedure TTestResolver.TestUnit_DuplicateDottedUsesFail;
begin begin
AddModuleWithIntfImplSrc('ns.unit2.pp', AddModuleWithIntfImplSrc('ns.unit2.pp',