RFR: 8325859: potential information loss during type inference [v3]
Vicente Romero
vromero at openjdk.org
Thu May 15 15:28:54 UTC 2025
On Thu, 15 May 2025 15:17:44 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> > good catch, yes this is a bug in `Infer::shouldPropagate` and one we should fix for sure, but I think that the fundamental problem is still there and will show its head again as soon as, for example, the lambda is not void-compatible
>
> If the target type is non-void, then it will be checked by the `compatible` method I shown above. This is a deferred type check which will cause the inference context to be inferred in full. The problem of this issue is that the final inference step is never executed -- because the target type is `void`.
>
> If you can find a case w/o `void` that exhibits the same issue, we can certainly look into that more.
I'm seeing the same issue as the one reported with this test case:
import java.util.function.*;
class Generic {
public static void main(String... args) {
runT(() -> supplyNull(Integer.valueOf(1)));
}
static <R, X> R supplyNull(X... varargs) {
System.out.println(varargs.getClass().getComponentType());
return null;
}
static <T> void runT(Supplier<T> supp) { supp.get(); }
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25011#issuecomment-2884239036
More information about the compiler-dev
mailing list