-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Java: Fix WildcardTypeAccess.hasNoBound() not considering ArrayTypeAccess #5407
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
| locations/C.java:6:7:6:7 | ? ... | | ||
| locations/C.java:7:7:7:22 | ? ... | | ||
| locations/C.java:8:7:8:20 | ? ... | | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,30 @@ | ||||||
import default | ||||||
import TestUtilities.InlineExpectationsTest | ||||||
|
||||||
from WildcardTypeAccess wta | ||||||
select wta | ||||||
private string getValue(WildcardTypeAccess wta) { | ||||||
if wta.hasNoBound() // also makes sure that hasNoBound() is working correctly | ||||||
then result = "" | ||||||
else | ||||||
// Also makes sure that getBound() is working correctly (and has at most | ||||||
// one result) | ||||||
exists(Expr bound | bound = wta.getBound() and not wta.getBound() != bound | | ||||||
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.
Suggested change
It's better to test the not-having-multiple-values by potentially observing those values rather than observing nothing. 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. Though then the test would also succeed when |
||||||
bound = wta.getUpperBound() and result = "u:" + bound | ||||||
or | ||||||
bound = wta.getLowerBound() and result = "l:" + bound | ||||||
) | ||||||
} | ||||||
|
||||||
class WildcardTypeAccessTest extends InlineExpectationsTest { | ||||||
WildcardTypeAccessTest() { this = "WildcardTypeAccessTest" } | ||||||
|
||||||
override string getARelevantTag() { result = ["wildcardTypeAccess"] } | ||||||
Marcono1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
override predicate hasActualResult(Location location, string element, string tag, string value) { | ||||||
exists(WildcardTypeAccess wta | | ||||||
location = wta.getLocation() and | ||||||
element = wta.toString() and | ||||||
tag = "wildcardTypeAccess" and | ||||||
value = getValue(wta) | ||||||
) | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
| typeaccesses/Arrays.java:4:2:4:9 | ...[] | | ||
| typeaccesses/Arrays.java:5:2:5:25 | ...[] | | ||
| typeaccesses/TA.java:19:43:19:50 | ...[] | | ||
| typeaccesses/TA.java:20:41:20:48 | ...[] | | ||
| typeaccesses/TA.java:31:80:31:82 | ...[] | | ||
| typeaccesses/TA.java:31:124:31:137 | ...[] | |
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.
Don't use abbreviations in qldoc.
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.
Made this a separate sentence ("... any. That is, ...") to be consistent with other comments and to not have so many commas.
(Though this might not be grammatically correct?)