RFR: 8318160: javac does not reject private method reference with type-variable receiver [v7]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Oct 18 20:38:49 UTC 2023


On Wed, 18 Oct 2023 18:22:00 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Please review this PR which is fixing a long standing regression in javac. Basically javac is accepting code like:
>> 
>> 
>> import java.util.function.*;
>> 
>> class Test {
>>     private String asString() {
>>         return "bar";
>>     }
>> 
>>     static <T extends Test> Function<T, String> foo() {
>>         return T::asString;
>>     }
>> }
>> 
>> 
>> this code should be rejected on the grounds that ::asString is a private method in class `Test` and thus not a member of type variable `T`
>> 
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   another implementation

Looks very good, thanks!

-------------

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16210#pullrequestreview-1686098389


More information about the compiler-dev mailing list