Generics - ancestor class and virtual method override lazarus / 62-General ---------------------------------------------------------------------- korba812 · 2022-02-13 15:44 I just discovered a new (for me) functionality for generic classes: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TFoo = class    function DoFoo: Integer; virtual;  end;   generic TBar = class(T)    function DoFoo: Integer; override; // <- Error: There is no method in an ancestor class to be overridden: "DoFoo:LongInt;"    function DoBar: Integer; virtual;  end; Unfortunately, there is no way to override virtual methods in this way. Is such a possibility planned? ---------------------------------------------------------------------- Thaddy · 2022-02-13 18:59 Of course not! That is programmer error. ---------------------------------------------------------------------- korba812 · 2022-02-13 19:33 It's a pity because it looks pretty useful. ---------------------------------------------------------------------- Martin_fr · 2022-02-13 19:44 There is an open bug https://gitlab.com/freepascal.org/fpc/source/-/issues/36843 ---------------------------------------------------------------------- korba812 · 2022-02-13 19:57 So where is the bug - whether the compiler allows to create such a generic class or that the compiler does not find virtual method in the ancestor class? ---------------------------------------------------------------------- Martin_fr · 2022-02-13 20:02 Quote from: korba812 on February 13, 2022, 08:57:10 pmSo where is the bug - whether the compiler allows to create such a generic class or that the compiler does not find virtual method in the ancestor class? Well there is no answer from the fpc team yet. I personally would expect that the override should work.... ---------------------------------------------------------------------- korba812 · 2022-02-13 20:29 Of course. Even in its present form, it is a very useful functionality.