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
.
Spring4D
parts that handleTTypeInfo
data will not barf. – PruritustkUnknown
:TMyEnum = ( a = 1, b = 2 );
– SitinaTValue := TValue.Empty;
will also produce atkUnknown
. – PereiraTypeInfo(TMyEnum)
so at least in XE (don't have a more recent version available right now) this would not even produce any PTypeInfo. Actually the RTTI is incomplete in these cases so having a field of TMyEnum is not having any TRttiType and methods with a parameter of that type return wrong data when callingTRttiMethod.GetParameters()
. – WeenyGetTypeKind
on a TValue that does not contain anything - which also was kinda broken in earlier versions of Delphi (like IsEmpty returned True when it contained a reference type that was nil which resulted in GetTypeKind to return tkUnknown and not the correct TypeKind like tkClass or tkInterface). TheGetTypeInfo
method returns nil. So actually the answer is no, there is no TypeInfo with TypeKind = tkUnknown.tkUnknown
actually means there is no TypeInfo available. – WeenyTValue.From<TMyEnum>( a )
andTValue.Kind
wastkUnknown
– SitinTypeInfo(TMyEnum)
or call ToString on that TValue - I bet it writes'(unknown)'
. And that is because of what I said earlier: no type info for TMyEnum. Look at the implementation ofTValue.From<T>
. I really wonder that it compiles but I guess the compiler just works around this issue by passing nil (debug intoTValue.Make
and check the passedATypeInfo
). – WeenyaTValue.Kind
returnstkUnknown
whileaTValue.TypeInfo
returns nil. – Pereira