-
Notifications
You must be signed in to change notification settings - Fork 29
Introduce @NullMarked aliasing
#1304
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
8ebb819
1366194
fce8b43
8131a52
01d464c
164b98e
39f2c9c
f71b68a
d8f2cb2
8b7e190
a3bbf87
967b18d
487025f
616efbe
c9cd722
dd1976d
1bd799d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| public class NullMarkedSuppressError { | ||
| @org.jspecify.annotations.NullMarked | ||
|
aosen-xiong marked this conversation as resolved.
Outdated
|
||
| class A { | ||
| // :: error: (assignment.type.incompatible) | ||
| Object o = null; | ||
| } | ||
|
|
||
| class B { | ||
| Object o = null; | ||
|
aosen-xiong marked this conversation as resolved.
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import org.checkerframework.checker.nullness.qual.Nullable; | ||
| import org.checkerframework.checker.signature.qual.ClassGetName; | ||
| import org.checkerframework.dataflow.cfg.visualize.CFGVisualizer; | ||
| import org.checkerframework.framework.qual.AnnotatedFor; | ||
| import org.checkerframework.framework.qual.SubtypeOf; | ||
| import org.checkerframework.framework.source.SourceChecker; | ||
| import org.checkerframework.framework.type.AnnotatedTypeFactory; | ||
|
|
@@ -25,6 +26,7 @@ | |
| import java.util.Set; | ||
|
|
||
| import javax.lang.model.element.AnnotationMirror; | ||
| import javax.lang.model.element.Element; | ||
|
|
||
| /** | ||
| * An abstract {@link SourceChecker} that provides a simple {@link | ||
|
|
@@ -313,4 +315,31 @@ public BaseTypeChecker getUltimateParentChecker() { | |
| causeMessage); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * This method is almost similar to {@link | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to find a solution without this duplication.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With code refactoring in #1331, we can get rid of this code duplication. EDIT: tested at aosen-xiong#13. |
||
| * org.checkerframework.framework.util.defaults.QualifierDefaults#isElementAnnotatedForThisChecker(Element)}. | ||
| * except for early return if element is null, the conservative default for "source" is not used | ||
| * and do not recursively check enclosing elements because the logic is implemented at call | ||
| * sites. | ||
| * | ||
| * @param elt the source code element to check, or null | ||
| * @return true if the element is annotated for this checker or an upstream checker | ||
| */ | ||
| @Override | ||
| protected boolean isAnnotatedForThisCheckerOrUpstreamChecker(@Nullable Element elt) { | ||
| if (elt == null || !useConservativeDefault("source")) { | ||
| return false; | ||
| } | ||
|
|
||
| boolean elementAnnotatedForThisChecker = false; | ||
| AnnotationMirror annotatedFor = getTypeFactory().getDeclAnnotation(elt, AnnotatedFor.class); | ||
|
|
||
| if (annotatedFor != null) { | ||
| elementAnnotatedForThisChecker = | ||
| getTypeFactory().doesAnnotatedForApplyToThisChecker(annotatedFor); | ||
| } | ||
|
|
||
| return elementAnnotatedForThisChecker; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.