Replace a downcast with a type constraint in EnumOption