Skip to content

Compare super in a @SideEffectsOnly annotation as this - #8662

Open
mernst wants to merge 1 commit into
typetools:masterfrom
mernst:sideeffectsonly-super-receiver
Open

mernst wants to merge 1 commit into
typetools:masterfrom
mernst:sideeffectsonly-super-receiver

Conversation

@mernst

@mernst mernst commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Land before #8040.

A @SideEffectsOnly annotation can name a field through super, as in @SideEffectsOnly("super.f"). When a method body was checked against such an annotation, the side-effected expressions had super rewritten as this, but the annotation's expressions did not. The comparison is syntactic, so super.f in the body never matched super.f in the annotation. This matters when the class has its own field f that hides the superclass's, because the method cannot write this.f or f in the annotation instead.

This pull request rewrites super as this in the annotation's expressions too. A field access records the field that it refers to, so the rewritten expression still denotes the superclass's field.

Test: checker/tests/sideeffectsonly/SuperSeonly.java. Without the change, assignsSuperField gets a false purity.incorrect.sideeffectsonly error.

@coderabbitai

coderabbitai Bot commented Nov 25, 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 20 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 d520b6c and 8462e2c.

Files selected for processing: 2

  • checker/tests/sideeffectsonly/SuperSeonly.java
  • framework/src/main/java/org/checkerframework/common/basetype/DisallowedSideEffects.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

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