Simple file, A.groovy:
javap -private B | grep foo
The 'String' is treated as a type parameter name. The reference 'String' in the foo method is mapped to this type parameter (clearly it shouldn't be) and when producing the code, String is erased to its upper bound of Object, hence foo(Object) in the bytecode.
Change it to this:
and it produces what you expect:
The problem is the genericParameterNames collection in the ResolveVisitor is never cleared, only augmented with new entries.
My solution that seems to work in groovy eclipse is to clear the parameter names at the end of visiting a classnode in ResolveVisitor. So at the end of