-
Notifications
You must be signed in to change notification settings - Fork 360
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
Correct AnnotatedIntersectionTypes #3790
Conversation
# Conflicts: # framework/src/main/java/org/checkerframework/framework/flow/CFTreeBuilder.java
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.
Overall, this looks good. Thanks! I have a couple clarifying questions.
* location of the intersection type. | ||
* | ||
* <p>For example, {@code @NonNull Object & @Initialized @Nullable Serializable} is changed | ||
* to {@code @NonNull @Initialized Object & @Initialized @NonNull Serializable}. |
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.
In this example, the annotation isn't just copied to the primary annotation location, but to every bound of the intersection.
Also, it would be helpful to indicate that the primary annotation location is different than all the annotations on the bounds. The example doesn't actually show the primary annotation location. So, I find the example a bit confusing.
@@ -1016,6 +990,26 @@ protected boolean visitIntersectionSupertype( | |||
return result; | |||
} | |||
|
|||
/** | |||
* An intersection is a subtype if one of its bounds is a subtype of {@code supertype}. |
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.
When this is called, have the primary annotations already been applied to every bound, so that each bound stands on its own without any need to refer to the primary annotations?
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.
Yes. This method is only called on fully-annotated types. That means that the intersection type has a primary annotation for every qualifier hierarchy.
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.
TOOD: Add comment.
Does this also fix #3569? Just curious. |
Yes, it does. Good catch. I have updated the pull request description and the linked issues. |
General facts about intersections in javac that should make this pull request easier to review:
a. For cast types, the intersection type is parsed into an IntersectionTypeTree.
b. For type variable upper bounds, the intersection type is parsed into a list of trees
Changes in this pull request:
Defaulting rules for the primary annotation of an intersection type:
Warning:
If any explicit annotation on a bound is not the same as the primary annotation, then a warning is issued. (I was going to put this in a separate pull request, but it needs to be in this one so that the test cases are easier to understand.)
Changes to AnnotatedIntersectionType:
getBounds
returns a list of the bounds of the intersection type. (This used to be done viadirectSuperTypes
method.Fixes #868; Fixes #3349; Fixes #3362; Fixes #3659.