add support for generic trait parameters

this probably needs some review since it seems that sometimes we're
visiting certain params twice