Can not call a private method, no idea why ?

Remi Forax forax at univ-mlv.fr
Thu Jan 21 08:32:24 UTC 2021


The following code doesn't compile.
No idea why ?

public interface IOBug {
  private IOBug foo() {
    return this;
  }

  default IOBug flatMap(Function<? super Object, ? extends IOBug> map) {
    return map.apply(null).foo();
                           ^------
  }
}

It works if foo is declared as a default method instead of a private method.

regards,
Rémi


More information about the compiler-dev mailing list