resolving several ivars to the same capture?

Vicente Romero vicente.romero at oracle.com
Thu Oct 23 16:48:41 UTC 2025



On 10/23/25 12:04, Stephan Herrmann wrote:
> Am 23.10.25 um 17:10 schrieb Maurizio Cimadamore:
>>
>> On 23/10/2025 15:53, Maurizio Cimadamore wrote:
>>>>> Yes, but that means that we will generate “spurious” capture 
>>>>> variables during inference which will end up in the result. 
>>>>> Depending on the case, this might result in failures.
>>>>
>>>> define "spurious"! 🙂
>>> I think Dan has explored this topic in more details and might have 
>>> more examples of when the extra captures generated during 
>>> incorporation might lead to bad inference results. I'll leave this 
>>> with him.
>>
>> Actually, here's a possible example:
>>
>> class Test {
>>      static class A<X> { }
>>      static class B<X> { }
>>      static class C<X> extends B<X> { }
>>
>>      static <Z> void m(A<? extends B<Z>> a) { }
>>
>>      static void test(A<C<?>> a) {
>>          m(a);
>>      }
>> }
>
> ecj accepts this (since 2017). Is that a problem?
>
> It seems ecj succeeds, because repeated capture requests are detected 
> to be asking the exact same question (same wildcard, same code 
> location), so the same capture may be answered more than once.
>
> Stephan

we also do some capture caching in javac but it is very limited, I would 
love to extend its reach, but still we would need some spec blessing here

Vicente


More information about the compiler-dev mailing list