superobject
superobject copied to clipboard
superobject doesn't compile in Delphi 10.2 Tokyo
In Delphi 10.2 Tokyo, unit superobject.pas stops compiling, with error: "E2036 Variable required" on this line:
if CompareMem(@GetTypeData(TypeInfo).Guid, @soguid, SizeOf(TGUID)) then
This is located in procedure FromInterface inside function TSuperRttiContext.FromJson
This code compiled without issues in Delphi 10.1 Berlin.
I've fixed my local copy by declaring a new variable
var
varGuid: TGUID;
and then using it like this:
varGuid := GetTypeData(TypeInfo).Guid;
if CompareMem(@varGuid, @soguid, SizeOf(TGUID)) then
and it seems to work correctly in my testing, but I am not sure if this is the correct solution in this case.
You make copy of GUID record, this solution is imho syntactically correct but not optimal (unnecessary memory copying)
you can change it like this
if isEqualGUID(GetTypeData(TypeInfo).Guid, soguid) then