[Lazarus] inherited in autocode

Martin Frb lazarus at mfriebe.de
Sat Jan 12 22:28:59 CET 2019


On 12/01/2019 21:19, Bart via lazarus wrote:
> On Sat, Jan 12, 2019 at 7:18 PM Carlos Eduardo S. M. via lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
>
>> What if the line "inherited;" is automatically included when using code completion (<Ctrl><Shift>C) for constructor, destructor, CreateForm, DestroyForm, etc.? Instead of
> It already does if the method is declared with override.
>

Just "inherited" for constructors is afaik/iirc a major danger.

IIRC It only calls the parent method, if the parent method has the exact 
same signature.

If the call is made from within an "override" method, that is fine, 
because the override will fail if the parent changes.

If your method was re-introduced (maybe without the keyword / 
effectively hiding the parent), and the parent method changes, the 
"inherited" compiles (no error, no warning) but it will generate no code.
Same for constructors, if the parent constructor changes its argument 
list, it will no longer be called.

That is indented behaviour and apparently Delphi compatible.

So always use the fully qualified call "inherited create;" (or with args 
as needed)


More information about the lazarus mailing list