Introspected arrays cannot be cast back to Array(Of T)
- Status
- Fixed
- Fixed in
- v26.6.4
- Source discussion
- -
- Last updated
- 2026-06-15
Public summary
Reading an Array property through introspection returns an Object value that cannot be cast back to Array(Of T) or Array(Of Object). The runtime raises TypeMismatchException: Cannot cast 'Array' to 'Array', which blocks serializers and other reflection-style code from reading array properties.\n\n### Source discussion\nhttps://forum.objo.dev/d/366-trouble-with-reading-array-via-introspection\n\n### Reproduction notes\nobjo\nClass Address\nEnd Class\n\nClass Customer\n Property Addresses As Array(Of Address)\n\n Constructor()\n Addresses = [New Address()]\n End Constructor\nEnd Class\n\nVar c As New Customer()\nVar prop As Object = TypeOf(c).Property("Addresses")\nVar value As Object = prop.GetValue(c)\nVar typed As Array(Of Address) = Array(Of Address)(value)\nPrint(typed.Count)\n\n\nExpected: prints 1.\nActual: runtime TypeMismatchException: Cannot cast 'Array' to 'Array'.\n\n### Internal notes\nPropertyInfo.GetValue returns the correct VM array value, but OpCode.Cast currently validates primitives and class instances only. ObjoArray is a VM-native value whose Class is null, so the reference-type cast path never accepts it. The cast target for Array(Of T)(...) is currently emitted as the erased base type name Array, so the immediate fix is to accept VM array values for Array casts and add a regression test for introspected Array(Of Address) and Array(Of Object) casts.