-
Notifications
You must be signed in to change notification settings - Fork 299
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
JSpecify: fix crash with calls to static methods #856
JSpecify: fix crash with calls to static methods #856
Conversation
…ot from method invocation raw type
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #856 +/- ##
============================================
+ Coverage 86.93% 86.95% +0.01%
- Complexity 1886 1889 +3
============================================
Files 74 74
Lines 6215 6215
Branches 1208 1208
============================================
+ Hits 5403 5404 +1
Misses 405 405
+ Partials 407 406 -1
☔ View full report in Codecov by Sentry. |
…estForGuavaRawTypeBuildIssue
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.
Thanks for the fix! Couple of comments
@@ -1494,12 +1494,40 @@ public void interactionWithContracts() { | |||
.doTest(); | |||
} | |||
|
|||
@Test | |||
public void testForGuavaRawTypeBuildIssue() { |
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.
Rather than pulling in Guava here, let's just test for the core issue of static method calls of the form X.foo()
where X
is there explicitly. You should be able to write a standalone test case that exposes the previous crash, without importing Guava or adding the makeHelperWithGuava()
method
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.
I agree. I have changed the test case to reproduce this scenario without using importing guava and ImmutableSet. Let me know if this works. I have removed the helper which imports guava too.
nullaway/build.gradle
Outdated
@@ -152,7 +152,7 @@ tasks.register('buildWithNullAway', JavaCompile) { | |||
sourceSets.main.compileClasspath) | |||
options.errorprone.enabled = true | |||
options.errorprone { | |||
option("NullAway:AnnotatedPackages", "com.uber,org.checkerframework.nullaway") | |||
option("NullAway:AnnotatedPackages", "com.uber,org.checkerframework.nullaway,com.google.common") |
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.
Now that I think of it, let's not add this change here, and instead do it in a separate follow-up PR, just to make things cleaner
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.
Makes sense, I have removed it from this branch.
…of being specific to guava ImmutableSet
…_issue_abhijitk' into jspecify_buildWithNullAway_guava_issue_abhijitk
@@ -1494,6 +1494,34 @@ public void interactionWithContracts() { | |||
.doTest(); | |||
} | |||
|
|||
@Test | |||
public void testForStaticMethodCallAsAParam() { |
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.
@akulk022 have you confirmed that this test fails with two unexpected errors if you remove the fixes in GenericsChecks?
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, I verified it for both scenarios by removing the fix and seeing if the test case fails with the same exception as before.
After adding com.google.common to annotated packages for buildWithNullAway in JSpecify Mode, we got the following exception:
With the call to
java ImmutableSet.of()
which is a static call, we were wrongly trying to return null from getTreeType in GenericChecks.java for this case which caused the above Exception.A unit test which reproduces the issue has been added to NullAwayJSpecifyGenerickChecks.java:
All the unit tests from the NullAway build have passed for these changes.