Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Delphi version that can emit RTTI containing tkUnknown?

Tags:

delphi

rtti

Just to make sure I'm not overlooking a strange edge case as I've found yet a case that produce it, but I want to make sure:

Is there any Delphi version that can emit RTTI containing a type that has tkUnknown as TTypeKind?

If so:

  • any documentation reference?
  • what type would produce it?

In the current Delphi XE5 RTL, the only place I could find handling tkUnknown is TValue, but I've not found a code path in the RTL that sets up a TValue containing a TypeInfo having tkUnknown as Kind.

like image 462
Jeroen Wiert Pluimers Avatar asked Mar 01 '14 09:03

Jeroen Wiert Pluimers


1 Answers

The answer is no. Anything else would be a bug in the compiler.

tkUnknown is the indication that there is no type info available which might be the case for discontiguous enumerations and enumerations which don't start at zero (as explained by Barry here) and some types from long ago (like Real48).

It also is returned by TValue.Kind when TValue.IsEmpty is true. (since XE2 afaik before it also could return True in cases where it held a reference type that was nil which was a bug).

When you are retrieving RTTI for something that does not contain type info (like a field, property or parameter of a type that has no type info) your RTTI information is incomplete. TRttiField.FieldType and TRttiProperty.PropertyType return nil in these cases and the array returned by TRttiMethod.GetParameters is incomplete.

While it is possible to call TValue.Make<T> with a type that has no type info you will not be able to do much with this because its TypeInfo will be nil. The compiler obviously works around E2134 and passes nil to TValue.Make. Thus TValue.Kind will say tkUnknown.

like image 181
Stefan Glienke Avatar answered Nov 03 '22 02:11

Stefan Glienke