Can not call a private method, no idea why ?
forax at univ-mlv.fr
forax at univ-mlv.fr
Thu Jan 21 10:59:13 UTC 2021
> De: "Anna Kozlova" <anna.kozlova at jetbrains.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Jeudi 21 Janvier 2021 11:53:18
> Objet: Re: Can not call a private method, no idea why ?
> 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?
Why the type (? extends IOBug) and not the corresponding class, the erasure (IOBug) is used here to check the method access ?
> Thanks,
> Anna
regards,
Rémi
> On Thu, Jan 21, 2021 at 9:34 AM Remi Forax < [ mailto:forax at univ-mlv.fr |
> 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/4815fedb/attachment-0001.htm>
More information about the compiler-dev
mailing list