codetools: fixed TFindDeclarationTool.FindOverridenMethodDecl searching next ancestor

This commit is contained in:
mattias 2025-03-10 08:52:23 +01:00
parent 12afdd137b
commit c36f3fe0a5
2 changed files with 15 additions and 8 deletions

View File

@ -12314,14 +12314,14 @@ begin
end
else if Node.Desc in AllSimpleIdentifierDefinitions then begin
if CompareIdentifiers(@CurTool.Src[Node.StartPos],Identifier)=0 then
exit;
exit; // ancestor has field or constant with same name -> stop
end else if Node.Desc=ctnProperty then begin
CurIdentifier:=GetPropertyNameIdentifier(Node);
if CompareIdentifiers(CurIdentifier,Identifier)=0 then
exit;
exit; // ancestor has property with same name -> stop
end else if Node.Desc=ctnProcedure then begin
CurIdentifier:=CurTool.GetProcNameIdentifier(Node);
//debugln([' TFindDeclarationTool.FindOverridenMethodDecl PROC "',CurIdentifier,'"']);
//debugln([' TFindDeclarationTool.FindOverridenMethodDecl PROC "',GetIdentifier(CurIdentifier),'"']);
if CompareIdentifiers(CurIdentifier,Identifier)=0 then begin
// found ancestor method with same name
{$IFDEF VerboseFindRefMethodOverrides}
@ -12367,7 +12367,7 @@ begin
end else if Node.Desc=ctnGenericType then begin
if (Node.FirstChild<>nil)
and (CompareIdentifiers(@Src[Node.FirstChild.StartPos],Identifier)=0) then
exit;
exit; // ancestor has a generic type with same name -> stop
end;
// next
if Node.PriorBrother<>nil then
@ -12375,12 +12375,15 @@ begin
else begin
repeat
Node:=Node.Parent;
if Node=ClassNode then exit;
if Node=ClassNode then begin
Node:=nil;
break;
end;
until Node.PriorBrother<>nil;
if Node=nil then break;
Node:=Node.PriorBrother;
end;
end;
end;
finally

View File

@ -805,7 +805,9 @@ begin
' TAnimal = class',
' procedure Fly{#Rename}; virtual;',
' end;',
' TBird = class(TAnimal)',
' TFlying = class(TAnimal)',
' end;',
' TBird = class(TFlying)',
' procedure Eat;',
' procedure Fly; override;',
' end;',
@ -840,7 +842,9 @@ begin
' TAnimal = class',
' procedure Run{#Rename}; virtual;',
' end;',
' TBird = class(TAnimal)',
' TFlying = class(TAnimal)',
' end;',
' TBird = class(TFlying)',
' procedure Eat;',
' procedure Run; override;',
' end;',