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

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Oct 17 12:20:55 UTC 2023


On Tue, 17 Oct 2023 00:26:00 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   additional test
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java line 3555:
> 
>> 3553:         MethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
>> 3554:                 List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
>> 3555:             super(referenceTree, name, types.skipTypeVars(site, true, true), argtypes, typeargtypes, maxPhase);
> 
> I believe the right thing here should be to skip captured type variables but not "non-captured" type variables

Not sure... if you have:

class Foo<X> {
   X get()
}

And then:


static Function<?, String> m2(Foo<? extends Test> foo) {
        return foo.get()::asString2;
    }
 ```
 
 Don't you end up with a similar issue?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16210#discussion_r1362021487


More information about the compiler-dev mailing list