Skip to content
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

Apply declaration bounds to string conversions and binary comparisons #213

Merged
merged 32 commits into from
Jun 3, 2022

Conversation

zcai1
Copy link
Collaborator

@zcai1 zcai1 commented Apr 6, 2022

This PR is based on #212

Previously, string conversion node gets the same value as its operand has. This behavior is error prone because the annotations of its operand could be the supertypes of String's declaration bounds. This PR fixes such issue using the following rules:

  1. If the operand is a type variable and has no annotations, we apply its effective annotations instead.
  2. Otherwise, the operand should always have some annotations. For each annotation, if its a subtype of the string declaration bound in the same hierarchy, we add it to the result value; otherwise, we add the bound to the result value.

One new issue is also introduced by this PR: opprop#208

Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll look at this in detail once #212 is merged.

@zcai1 zcai1 force-pushed the apply-bounds-to-string-conversion-node branch from eead7d5 to 429a905 Compare April 13, 2022 08:20
@zcai1 zcai1 force-pushed the apply-bounds-to-string-conversion-node branch from 429a905 to 1deedb7 Compare April 13, 2022 08:23
Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work on this, especially the extensive tests! I have a bunch of comments we can discuss.

Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all these fixes! I only have small comments.
Can you expand the changelog to mention these changes?
Also, should the PR title be a bit more general now?

@@ -336,6 +336,17 @@ public static boolean isBooleanType(TypeMirror type) {
return isDeclaredOfName(type, "java.lang.Boolean") || type.getKind() == TypeKind.BOOLEAN;
}

/**
* Checks if the type represents a character type, that is either char (primitive type) or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this is similar to the comment on the above method, but shouldn't it be that is, is either...? At the moment, doesn't this mean that there are other possible options for "character type", but we return true only for these two?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this means we are checking if the given TypeMirror is a boxed or primitive character type. Could you please elaborate on "other possible options"?

Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wmdietl wmdietl changed the title Apply declaration bounds to string conversion node Apply declaration bounds to string conversions and binary comparisons Jun 3, 2022
@wmdietl wmdietl merged commit 7f9e27b into eisop:master Jun 3, 2022
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.

2 participants