Is there a version of Delphi that can emit RTTI containing tkUnknown?

Just to make sure that I don’t forget about the strange case of the region, since I found another case that produces it, but I want to make sure:

Is there a version of Delphi that can emit an RTTI containing the type tkUnknown as TTypeKind ?

If yes:

  • any link to the documentation?
  • what type will this produce?

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

+7
rtti delphi
source share
1 answer

The answer is no. Anything else would be a compiler error.

tkUnknown is an indication of the lack of type information that may occur for non-contiguous enumerations and enumerations that do not start from scratch (as Barry explains here ) and some types from ancient times (for example, Real48 ).

It also returns TValue.Kind when TValue.IsEmpty is true. (since XE2 afaik could also return True before, in those cases when it contained a reference type, which was zero, which was an error).

When you retrieve RTTI for something that does not contain type information (such as a field, property, or type parameter that does not have type information), your RTTI information is incomplete. TRttiField.FieldType and TRttiProperty.PropertyType return zero in these cases, and the array returned by TRttiMethod.GetParameters is incomplete.

Although you can call TValue.Make<T> with a type that does not have type information, you cannot do much with this because its TypeInfo will be zero. The compiler obviously runs around E2134 and passes nil to TValue.Make . So TValue.Kind will say tkUnknown .

+8
source share

All Articles