Today I wanted to check whether the OmniThreadLibrary plays nice with XE3 (yes, I know, I’ve should have done this weeks ago, but there was simply not enough time) and I was completely surprised when OtlSync unit couldn’t be compiled due to an internal error G9413.
One hour later I have reduced the problem to a simple test case (below) and to a simple fix. So the OmniThreadLibrary will be supported in the XE3 (as we all hoped for).
For other poor souls that may have run into this problem, here’s a small test case and a workaround.
implementation
uses
RTTI;
type
TTest<T> = class
procedure Test;
end;
var
a: IInterface;
procedure TTest<T>.Test;
var
aMethCreate: TRttiMethod;
begin
if Length(aMethCreate.GetParameters) = 0 then
;
end;
initialization
a := nil;
end.
The problem here is that the G9413 internal error is not reported on the line which causes the problem. The real culprit here is the ‘if Length(aMethCreate.GetParameters)’ call in the ‘TTest<T>.Test’ method.
To fix the problem it is enough to introduce a temporary variable that stores the result of the GetParameters call.
unit Unit136;
interface
implementation
uses
RTTI;
type
TTest<T> = class
procedure Test;
end;
var
a: IInterface;
procedure TTest<T>.Test;
var
aMethCreate: TRttiMethod;
params : TArray<TRttiParameter>;
begin
params := aMethCreate.GetParameters;
if Length(params) = 0 then
;
end;
initialization
a := nil;
end.
The problem is reported as QC #108942.