Skip to content

Bare inherited fails to resolve parent message handler with different signature #271

Open
@Cirras

Description

@Cirras

Prerequisites

  • This bug is in SonarDelphi, not SonarQube or my Delphi code.
  • This bug has not already been reported.

SonarDelphi version

1.7.0

SonarQube version

No response

Issue description

SonarDelphi does not currently implement the following behavior around message handlers.

When inherited has no identifier after it, it refers to the inherited method with the same name as the enclosing method or, if the enclosing method is a message handler, to the inherited message handler for the same message. In this case, inherited takes no explicit parameters, but passes to the inherited method the same parameters with which the enclosing method was called.

See https://docwiki.embarcadero.com/RADStudio/Athens/en/Methods_(Delphi)#Inherited

Steps to reproduce

In the below code example, the inherited in TBar.Bar should resolve to TFoo.Foo.

Minimal Delphi code exhibiting the issue

unit Example;

interface

type
  TFoo = class(TObject)
    procedure Foo(var Msg: TWMSize); message WM_SIZE;
  end;

  TBar = class(TFoo)
    procedure Bar(var Msg: TMessage); message WM_SIZE;
  end;

implementation

procedure TFoo.Foo(var Msg: TWMSize);
begin
  // ...
end;

procedure TBar.Bar(var Msg: TMessage);
begin
  inherited; // This should call TFoo.Foo
  // ...
end;

end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions