Fix a regression introduced by d84a165c8e799d8734df5f51a6dcf12b1f2a3695. Unbox casts were failing for enums. Fixes #14026.