RFR: 8310905: [lw5] addressing review comments on null restricted types [v4]

Vicente Romero vromero at openjdk.org
Wed Jul 12 21:40:17 UTC 2023


On Wed, 12 Jul 2023 09:43:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   adding more regression tests
>
> test/langtools/tools/javac/bang/BangTypesCompilationTests.java line 359:
> 
>> 357:                                 Result.Warning,
>> 358:                                 "compiler.warn.unchecked.nullness.conversion",
>> 359:                                 2),  // this needs to be reviewed, the warning is printed twice, should be once only
> 
> Does this have to do with the fact that the subtyping is executed twice (e.g. once in overload, once in the "check" phase) ?

for some cases like:

import java.util.function.*;
class Test {
    void plot(Function<String!, String> f) {}
    void m(Function<String, String> gradient) {
        plot(gradient);
    }
}

it was warning twice, there is a double visit by NullabilityComparator to the type. In method IsSubtype::visitClassType, there was a warning being issued when the arguments were compared and then at the end of the method this invocation:


    if (result) {
        nullabilityComparator.reset((t1, t2) -> hasNarrowerNullability(t1, t2)).visit(s, t);
    }

was provoking the same warning being issued in the same position. We need this invocation to compare the types but it also compares the arguments thus the double warning. I'm using now a field to mark if we have already warned or not.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/880#discussion_r1261749138



More information about the valhalla-dev mailing list