add generics support to the trait injector

This may be generally useful but in particular we need this for grails-data-mapping now.