Integrated: 8318160: javac does not reject private method reference with type-variable receiver

Vicente Romero vromero at openjdk.org
Tue Oct 24 14:48:49 UTC 2023


On Tue, 17 Oct 2023 00:19:56 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

This pull request has now been integrated.

Changeset: e2720987
Author:    Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e2720987b921b95fd8010cea60d2d6e436e5ebaa
Stats:     50 lines in 3 files changed: 50 ins; 0 del; 0 mod

8318160: javac does not reject private method reference with type-variable receiver

Reviewed-by: mcimadamore

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

PR: https://git.openjdk.org/jdk/pull/16210


More information about the compiler-dev mailing list