Generic type code not working