RFR: 8325859: potential information loss during type inference [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu May 15 16:49:00 UTC 2025


On Fri, 2 May 2025 18:00:43 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Vicente Romero has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>> 
>>  - Merge branch 'master' into JDK-8325859
>>  - make visitor static
>>  - updating doc
>>  - 8325859: potential information loss during type inference
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java line 271:
> 
>> 269:         if (next != null) {
>> 270:             HasTypeVars hasTypeVars = new HasTypeVars();
>> 271:             while (next != null && hasTypeVars.visit(result)) {
> 
> I think that we should be fine just going for the next supplementaryIC instead of traversing the whole list here. Same for the process to add free listeners, but in the first version I preferred to err on the correctness / completeness side. If we decide to visit more than one chained supplementary IC we can still do some improvements to try to reduce the number of supplementary ICs visited to a minimum

Maybe we can replace the visitor with asking `supplimentaryIC.free(t)` ? e.g. this could maybe use recusion?


Type result = t;
if (current.free(t)) {
    result = types.subst(t, inferencevars, instTypes());
}
if (supplimentaryIC != null) {
    return supplimentaryIC.asInstTypes(t);
 }
 ```

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25011#discussion_r2091599832


More information about the compiler-dev mailing list