Search code examples
delphiparametersdelphi-xe2interface-implementation

Is it supposed to be possible for methods to be missing their arguments in the implementation?


I face some common IDE bugs in Delphi XE2 (RAD Studio) but the problems themselves aren't my concern. It's the result of one of these bugs which made me stumble on something else.

Somehow, auto-completion decided to destroy a few methods of a form, so what used to be...

procedure TForm1.Button1Click(Sender: TObject);

in the implementation became something like...

procedure TForm1.Buproced(Sendure :);

(Not exact, but to some extent like that)

So, I had to manually fix these methods. However, I accidentally fixed one of them to...

procedure TForm1.Button1Click;

although it was supposed to have been...

procedure TForm1.Button1Click(Sender: TObject);

yet it still compiled and ran fine.

To test, start a new VCL Forms Application and drop just one TButton control, make an event handler for OnClick, and change its procedure to...

procedure TForm1.Button1Click;
var
  B: TButton;
begin
  B:= TButton(Sender);
  B.Caption:= 'Something';
end;

Is this supposed to be possible? Or is it perhaps an IDE and/or compiler bug?


Solution

  • In Delphi, you can omit the parameters in the implementation. It's not a bug, it's a feature.

    The proper method signature is evaluated by the declaration in interface section.