Thanks, this is fixed for the next build: https://feedback.objo.dev/bug/554
The issue was not specific to introspection. PropertyInfo.GetValue() returns Object, and the actual runtime value inside that Object can be a native value type such as DateTime.
This should work:
Var dt As DateTime = DateTime(prop.GetValue(instance))
but the VM’s runtime cast path had drifted from the IsA path. IsA knew that a runtime DateTime value was a DateTime, but Cast did not recognise all of the same VM-native value types. That’s why the error looked paradoxical:
Cannot cast 'DateTime' to 'DateTime'
For the next build, IsA and explicit runtime casts now share the same runtime assignability logic. This fixes boxed DateTime values and also covers the same class of issue for Colour, native heap values, class/interface casts, and supported built-in interfaces.
So this remains a compile-time error by design:
Var dt As DateTime = prop.GetValue(instance)
because that is an implicit Object -> DateTime downcast.
But this now works as intended:
Var dt As DateTime = DateTime(prop.GetValue(instance))