-
Notifications
You must be signed in to change notification settings - Fork 437
Add @DoesNotUnrefineReceiver annotation
#7640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
71c81e7
Add `@DoesNotUnrefineReceiver` annotation
mernst b49b571
Add field
mernst 417bc1a
Fix element definition
mernst 3dc8d87
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 8bd3880
Complete the feature
mernst 4e788d5
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 0c665a5
Fix method name
mernst be6d64a
CodeRabbit
mernst a4994ad
Update framework/src/main/java/org/checkerframework/framework/flow/CF…
mernst ace58f0
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 612220a
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 45c19f9
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 99dfc2f
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst 27cc075
Move annotation and method
mernst 0425a81
Merge ../checker-framework-branch-master into does-not-unrefine-receiver
mernst ec45388
Add simple test case.
smillst 01c42c7
Merge branch 'master' into does-not-unrefine-receiver
smillst 45190a1
Don't put JDK annotations in stub files; they belong in the annotated…
mernst 2450365
Merge ../checker-framework-fork-mernst-branch-jdk-annotations-in-jdk …
mernst 69f2602
Add expected warnings that are false positives
mernst f4b10cb
Fix comment
mernst 07b6b69
Tweaks in annotation definitions
mernst 54f251a
Improve wording
mernst 1db2897
Add `@return`
mernst 6b1fa23
Add InheritedAnnotation
smillst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
checker-qual/src/main/java/org/checkerframework/framework/qual/DoesNotUnrefineReceiver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.checkerframework.framework.qual; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * At a call to a side-effecting method, the framework ordinarily discards all refined type | ||
| * information, since the side-effecting method might invalidate that information. This annotation | ||
| * indicates that, at a call to the annotated method, the receiver's type should not be unrefined. | ||
| * That is, a call to the method does not affect the type qualifier (in the given hierarchy). | ||
| * | ||
| * @checker_framework.manual #type-refinement-purity Side effects, determinism, purity, and | ||
| * flow-sensitive analysis | ||
| */ | ||
| @Documented | ||
| @InheritedAnnotation | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) | ||
| public @interface DoesNotUnrefineReceiver { | ||
| /** | ||
| * The name of the checker(s) that this annotation affects. For example, "modifiability" or | ||
| * "nullness". Use "allcheckers" to affect all checkers. | ||
| * | ||
| * @return the name of the checker that this annotation affects | ||
| */ | ||
|
mernst marked this conversation as resolved.
|
||
| String[] value(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
checker/src/main/java/org/checkerframework/checker/rlccalledmethods/jdk.astub
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import org.checkerframework.checker.tainting.qual.Untainted; | ||
| import org.checkerframework.framework.qual.DoesNotUnrefineReceiver; | ||
|
|
||
| public class TestDoesNotUnrefine { | ||
| static class MyClass { | ||
|
|
||
| @DoesNotUnrefineReceiver("tainting") | ||
| String doesNotUnrefine() { | ||
| return ""; | ||
| } | ||
|
|
||
| String doesUnrefine() { | ||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| MyClass field; | ||
|
|
||
| void test(@Untainted MyClass untainted) { | ||
| field = untainted; | ||
| field.doesNotUnrefine(); | ||
| @Untainted MyClass anotherLocal = field; | ||
|
|
||
| field.doesUnrefine(); | ||
| // :: error: [assignment] | ||
| @Untainted MyClass anotherLocal2 = field; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: typetools/checker-framework
Length of output: 50383
Remove
ElementType.CONSTRUCTORor implement constructor handling.Line 21 allows this annotation on constructors, but verification shows
hasDoesNotUnrefineReceiver()is called only inCFAbstractStore.updateForMethodCall(MethodInvocationNode, ...). No constructor/object-creation flow paths check this annotation. Constructor annotations will be accepted but silently ineffective.Fix if constructors are not intended to be supported
📝 Committable suggestion
🤖 Prompt for AI Agents