<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 23/10/2025 15:53, Maurizio
Cimadamore wrote:<br>
</div>
<blockquote type="cite" cite="mid:3986cc58-ceac-4d59-920f-acb4bc872451@oracle.com">
<blockquote type="cite" style="color: #8c8c8c;">
<blockquote type="cite" style="color: #8c8c8c;">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.
<br>
</blockquote>
<br>
define "spurious"! 🙂
<br>
</blockquote>
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.</blockquote>
<p>Actually, here's a possible example:</p>
<p>class Test {<br>
static class A<X> { }<br>
static class B<X> { }<br>
static class C<X> extends B<X> { }<br>
<br>
static <Z> void m(A<? extends B<Z>> a) { }<br>
<br>
static void test(A<C<?>> a) {<br>
m(a);<br>
}<br>
}</p>
<p>Here we run the subtyping check:</p>
<p>A<C<?>> <: A<? extends B<Z>><br>
</p>
<p>Which leads to</p>
<p>C<?> <: B<Z><br>
C<#CAP1> <: B<Z></p>
<p>Which leads to</p>
<p>Z == #CAP1</p>
<p>Ok, so the inferred type for m's parameter is A<? extends
B<#CAP1>></p>
<p>But is our actual argument (A<C<?>>) compatible with
that? Let's check</p>
<p>A<C<?>> <: A<? extends B<#CAP1>></p>
<p>Which leads again to:</p>
<p>C<?> <: B<#CAP1><br>
C<#CAP2> <: B<#CAP1><br>
false</p>
<p>Since we capture _again_, we end up with _two_ capture variables,
incompatible with each other.</p>
<p>So, inference was able to get to some kind of solution, but
unfortunately the inferred type is not compatible with the actual
argument we started with.</p>
<p>Maurizio</p>
<p><br>
</p>
<p><br>
</p>
</body>
</html>