resolving several ivars to the same capture?
Stephan Herrmann
stephan.herrmann at berlin.de
Thu Oct 23 16:04:05 UTC 2025
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
More information about the compiler-dev
mailing list