On Thu, 02 Jun 2011 13:10:14 -0400, Michael Shulman <viritril...@gmail.com> wrote:

Hi,

The following code fails the linker, complaining about an undefined
reference to 'foo':


interface A {
  private int foo();
}

class B {
  int bar(A x) { return x.foo(); }
}

void main() { }


But if I remove the 'private' qualifier on 'foo', then it succeeds.
Shouldn't B.bar() be able to access the private A.foo(), since they
are in the same package?  If I move the definition of A into another
package, then the *compiler* fails with "interface member not
accessible", as I would expect.

Private methods are non-virtual, so I'm pretty sure they are not supposed to be allowed in an interface.

But I suppose private could also mean private final, in which case you have to provide an implementation for foo in the interface.

This would be in line with the error message.

-Steve

Reply via email to