Attila Kovacs 629 Posted February 8, 2021 (edited) Since when does inherited work on properties? "Inherited Data". And where else except the obvious? Documentation? I was annoyed that I could not set FData as it is private so I gave him an "inherited" in anger and fury and the compiler wasn't complaining. 😮  TTreeNodeHelper = class helper for TTreeNode private function GetNodeData: TNodeData; procedure SetNodeData(const Value: TNodeData); public property Data: TNodeData read GetNodeData write SetNodeData; end; function TVariantenTreeNodeHelper.GetNodeData: TNodeData; begin Result := inherited Data; end; procedure TVariantenTreeNodeHelper.SetNodeData(const Value: TNodeData); begin inherited Data := Value; end;  Edited February 8, 2021 by Attila Kovacs Share this post Link to post
Lars Fosdal 1792 Posted February 8, 2021 That is interesting - and a little disturbing. Share this post Link to post
Uwe Raabe 2057 Posted February 8, 2021 48 minutes ago, Attila Kovacs said: Since when does inherited work on properties? At least since Delphi 7 (cannot check versions below in the moment). Just have a look at DB.pas (out of many others): function TFieldDefs.GetFieldDef(Index: Integer): TFieldDef; begin Result := TFieldDef(inherited Items[Index]); end; or the ancient Contnrs.pas: function TObjectList.GetItem(Index: Integer): TObject; begin Result := inherited Items[Index]; end;  1 Share this post Link to post
Attila Kovacs 629 Posted February 8, 2021 @Uwe Raabe Wow. Will turn out it's on the first page of the help 🙂 Share this post Link to post
Anders Melander 1783 Posted February 8, 2021 57 minutes ago, Attila Kovacs said: Since when does inherited work on properties? Delphi 1 1 1 Share this post Link to post
Alexander Elagin 143 Posted February 8, 2021 From the very beginning, i.e Delphi 1. What's the problem? Share this post Link to post
Attila Kovacs 629 Posted February 8, 2021 31 minutes ago, Alexander Elagin said: From the very beginning, i.e Delphi 1. Thx.  31 minutes ago, Alexander Elagin said: What's the problem? The gas prices. 😉 1 Share this post Link to post
Lars Fosdal 1792 Posted February 9, 2021 14 hours ago, Alexander Elagin said: From the very beginning, i.e Delphi 1. What's the problem? I guess private is not private - unless strict private? Share this post Link to post
Uwe Raabe 2057 Posted February 9, 2021 3 minutes ago, Lars Fosdal said: I guess private is not private - unless strict private? FData is private, but the helper sets inherited Data, which is public. 2 Share this post Link to post
Lars Fosdal 1792 Posted February 9, 2021 If it is public, why do you need to use inherited? I think the point just wooshed over my head here. (Not the first time) Share this post Link to post
Attila Kovacs 629 Posted February 9, 2021 @Lars Fosdal In this case I'm overriding the Data property, so this is the only way to set/get them. Share this post Link to post
Alexander Elagin 143 Posted February 9, 2021 Â 20 minutes ago, Lars Fosdal said: If it is public, why do you need to use inherited? Because Data property is re-introduced with a new signature, thus it is necessary to explicitly use the inherited property and not the new one. Share this post Link to post
Lars Fosdal 1792 Posted February 9, 2021 Ah - Brain fog cleared. Thanks, guys. Share this post Link to post
Alexander Elagin 143 Posted February 9, 2021 In fact, this was a pretty common trick when implementing ccustom lists before generics. 1 Share this post Link to post