Java method implementations whose arg types are broader than declared in the interface


What is the motivation for disallowing this in Java?

interface A { void foo(C arg); } interface B { void foo(D arg); } interface C {} interface D extends C {}

public class E implements A, B { public void foo(C arg) {} }

The compiler complains that E doesn't implement the foo(D) required by B.

I realise the underlying issue is that the following doesn't compile either:

public class F implements B { public void foo(C arg) {} }

but I don't understand why Java disallows it?

The original post had 8 comments I'm in the process of migrating over.