Skip to content

JointJavacJavaParserVisitor: assert that an Optional is present before calling get() - #8437

Merged
mernst merged 2 commits into
typetools:masterfrom
mernst:ajava-optional-asserts
Oct 28, 2026
Merged

mernst merged 2 commits into
typetools:masterfrom
mernst:ajava-optional-asserts

Conversation

@mernst

@mernst mernst commented Oct 27, 2026

Copy link
Copy Markdown
Member

Land before #8403.

Each of these calls to Optional.get() is guarded by a test on the javac tree, such as if (!javacTree.getTypeArguments().isEmpty()). An earlier assertion, such as assert javacTree.getTypeArguments().isEmpty() != node.getTypeArguments().isPresent(), relates that test to the Optional, but the Optional Checker cannot use a != between two method calls to conclude that the Optional is present. This pull request adds an assertion that the Optional is present, just before each get().

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between cd4d750 and 3919420.

Files selected for processing: 1
  • framework/src/main/java/org/checkerframework/framework/ajava/JointJavacJavaParserVisitor.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mernst mernst self-assigned this Oct 27, 2026
@mernst
mernst merged commit 0406812 into typetools:master Oct 28, 2026
29 checks passed
@mernst
mernst deleted the ajava-optional-asserts branch October 28, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant