Code Completion: Invalid event comparison in property setter

Summary

The auto-completion function for the following code:

program Project1;

type
  TEvent = procedure(Sender: TObject) of object;

  { TClass }

  TClass = class
  private
    FTest: TEvent;
  published
    // Set caret after "SetTest" and press [Ctrl+Shift+C]
    property Test: TEvent read FTest write SetTest;
  end;

begin
end.

automatically creates an assignment procedure:

procedure TClass.SetTest(AValue: TEvent);
begin
  if FTest=AValue then Exit;
  FTest:=AValue;
end;

But this is an invalid event comparison, it should be:

-  if FTest=AValue then Exit;
+  if SameMethod(TMethod(FTest), TMethod(AValue)) then Exit;

Links