Every couple of years, I'll stumble upon yet another Delphi compiler issue.
This time, here's the code that causes the problem.
program
Project4;
{$APPTYPE CONSOLE}
{$R *.res}
type
IFather =
interface
procedure
wait; cdecl; overload;
wait(millis:
Int64
); cdecl; overload;
; nanos:
Integer
end
;
ISon =
(IFather)
TSon =
class
(TInterfacedObject, ISon)
{ TSon }
TSon
.
wait;
begin
);
After doing class completion so that method stubs are generated for the wait overloads, the fun begins after trying a compile. The full list of compile errors are as below:
I turn to the official documentation and there's no hint to what's wrong. I seem to remember Joe White stumbled upon some issues years ago and he mentioned that there were 2 types of directives, but the solution isn't there.
Eventually, by intuition, I figured out that the overload directive should appear first, and that's it! Rearranging all declarations as follows made the code compile!
wait; overload; cdecl;
); overload; cdecl;
In addition, removing the semicolon (;) from the original code works as well.
I filed a bug report and noted the 2 workarounds. Either remove the semicolon, or rearrange method directives so that overload appears first.