Bug 6253 followup: explicitly check ref value for ARRAY before casting