Consider:
public interface Foo<T> {
public static class X{}
public void foobar(T t);
}
public class Bar<X> {
Foo<X> foo = new Foo<X>() {
public void foobar(X t) {}
};
}
I found no way to express that I mean the X from Bar<X> and not Foo.X in the foobar(X t) implementation. Is there no other way than renaming the generic parameter X in Bar or the static inner class?
I don't think there is a way to disambiguate to the type parameter, and I think that that was a reasonable design decision to make.
XinBar<X>. In other words, if you had the ability to sayfoobar(TypeParameter.X t)you would have the ability to simply use something other thanXfor the type parameter onBar. RenamingXis the way you avoid name clashes.Don't forget that type parameter names don't leak out to other classes in more than trivial ways. You are never forced to use a certain type parameter name, ever. So it makes sense that the language designers wouldn't have thought this is worth adding complexity to the language for.