Java methods are allowed to specify type parameters that may or may not be used to classify method parameters. Why are type params taken into account when matching method signatures (for the purpose of overriding)? Shouldn’t these unused params be thrown away? In other words, why doesn’t the below compile [in Java 21]?
public class Foo {
interface Bar {
void egg();
}
class Baz implements Bar {
@Override
public <T> void egg() {}
}
}
Is this just an oversight by language designers or is there a legitimate reason for the limitation?