On Fri, 9 Jan 2026 15:56:03 GMT, Vicente Romero <[email protected]> wrote:

>> generate missing null checks like for method arguments, return arguments, etc
>
> Vicente Romero has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   record patterns

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java 
line 102:

> 100:     /** Visitor argument: proto-type.
> 101:      */
> 102:     private Type pt;

This doesn't seem to be used?

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java 
line 133:

> 131:             !types.isNonNullable(rhsSym.type)) {
> 132:             tree.rhs = translate(tree.rhs, types.erasure(tree.lhs.type));
> 133:             tree.rhs = attr.makeNullCheck(tree.rhs, true);

Shouldn't we use `generateNullCheckIfNeeded` always? (here and elsewhere)

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java 
line 188:

> 186:     public void visitReturn(JCReturn tree) {
> 187:         if (returnType != null && !returnType.hasTag(VOID)) {
> 188:             if (types.isNonNullable(returnType) && 
> !types.isNonNullable(tree.expr.type)) {

I think tree.expr.type will be erased by now?

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java 
line 197:

> 195: 
> 196:     @Override
> 197:     public void visitLetExpr(LetExpr tree) {

Why is this needed? Isn't this the default behavior?

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 
3786:

> 3784:             return variableDeclarators(optFinal(0), parseType(true), 
> stats, true).toList();
> 3785:         } else {
> 3786:             JCExpression t = term(EXPR | TYPE | ALLOW_BANGS);

Good catches!

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1867#discussion_r2676793888
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1867#discussion_r2676796499
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1867#discussion_r2676789324
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1867#discussion_r2676787273
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1867#discussion_r2676803148

Reply via email to