When compiling the following code I get an error:
TOmniParallelSimplePooledLoop = class(TOmniParallelSimpleLoop)
procedure Execute(loopBody: TOmniIteratorSimpleSimpleDelegate); overload; override;
[dcc64 Error] OtlParallel.pas(846): E2170 Cannot override a non-virtual method
If I make the ancestor method virtual then the error goes away.
However the ancestor method is declared in:
IOmniParallelSimpleLoop
...
procedure Execute(loopBody: TOmniIteratorSimpleSimpleDelegate); overload;
Will the redeclaration of the base method in TOmniParallelSimpleLoop from non-virtual to virtual change the base type, or was the method already virtual to begin with (due to it being an implementation of an interface method)?
In other words: will the compiler output different code when an interfaced method is changed from non-virtual to virtual?
Basic MSVC to recreate the error
program Project70;
{$APPTYPE CONSOLE}
uses
System.SysUtils;
type
I1 = interface
procedure DoSomething;
end;
T1 = class(TInterfacedObject, I1)
procedure DoSomething;
end;
T2 = class(T1)
procedure DoSomething; override;
end;
procedure T1.DoSomething;
begin
WriteLn('parent');
end;
procedure T2.DoSomething;
begin
Writeln('Child');
end;
begin
end.