[groovy] refactor support of generics in compiled traits