THRIFT-4862 better ToString() support for enums and container types
Client: Delphi
Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Utils.pas b/lib/delphi/src/Thrift.Utils.pas
index 46e238c..11c4f3e 100644
--- a/lib/delphi/src/Thrift.Utils.pas
+++ b/lib/delphi/src/Thrift.Utils.pas
@@ -295,15 +295,18 @@
 { StringUtils<T> }
 
 class function StringUtils<T>.ToString(const value : T) : string;
+type PInterface = ^IInterface;
 var pType : PTypeInfo;
-    base  : ISupportsToString;
+    stos  : ISupportsToString;
+    pIntf : PInterface;  // Workaround: Rio does not allow the direct typecast
 begin
   pType := PTypeInfo(TypeInfo(T));
   if Assigned(pType) then begin
     case pType^.Kind of
       tkInterface : begin
-        if Supports(IInterface(value), ISupportsToString, base) then begin
-          result := base.toString;
+        pIntf := PInterface(@value);
+        if Supports( pIntf^, ISupportsToString, stos) then begin
+          result := stos.toString;
           Exit;
         end;
       end;