Can not call a private method, no idea why ?

Anna Kozlova anna.kozlova at jetbrains.com
Thu Jan 21 10:53:18 UTC 2021


Hi Remi,

type of  `map.apply(null)` is capture of `? extends IOBug` and thus it has
no access to private methods of IOBug. Do I miss something?

Thanks,
Anna

On Thu, Jan 21, 2021 at 9:34 AM Remi Forax <forax at univ-mlv.fr> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210121/c0a7a8fd/attachment.htm>


More information about the compiler-dev mailing list