RFR: [bworld] Emit lint warnings if overriding method does not have same nullability [v5]

Vicente Romero vromero at openjdk.org
Tue Feb 10 03:45:29 UTC 2026


On Tue, 10 Feb 2026 01:06:16 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> emit a lint warning for cases like:
>> 
>> class Test {
>>     String! m(String s) { return ""; }
>> }
>> class Sub extends Test {
>>     @Override
>>     String m(String s) { return null; }
>> }
>> 
>> or:
>> 
>> class Test {
>>     String m(String! s) { return ""; }
>> }
>> class Sub extends Test {
>>     @Override
>>     String m(String s) { return null; }
>> }
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   doc changes

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4009:

> 4007:             if (!types.isSameTypes(argTypes, lambdaTypes)) {
> 4008:                 checkContext.report(tree, diags.fragment(Fragments.IncompatibleArgTypesInLambda));
> 4009:             } else if (allowNullRestrictedTypes) {

I think we should the same with method references

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/2058#discussion_r2785632156


More information about the valhalla-dev mailing list