-
Notifications
You must be signed in to change notification settings - Fork 26
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
Updates to better match main-eisop
reference checker
#505
Updates to better match main-eisop
reference checker
#505
Conversation
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.
@cpovirk These are some changes I noticed when going through mismatches when using the main-eisop
reference checker.
@@ -43,7 +43,7 @@ interface SuperSuper<T extends @Nullable Object> { | |||
|
|||
void checkNeverNull(Lib<? extends Object> lib); | |||
|
|||
<U> void checkUnspecNull(Lib<@NullnessUnspecified U> lib); | |||
<U extends @Nullable Object> void checkUnspecNull(Lib<@NullnessUnspecified U> lib); |
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.
Without the more flexible bound, there are warnings about invalid inferred method type arguments.
As the bound of U
doesn't really matter, I think this doesn't change anything substantially.
Let me know if this isn't correct.
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 think that
jspecify/samples/ComplexParametric.java
Lines 21 to 25 in 8989d39
* Warning: I have probably gotten some things wrong in adding jspecify_* comments in this file. | |
* (Now, that may be the case for *any* file :) But it is particularly likely in this one.) | |
* Additionally, some checks would probably have different results under slightly different | |
* implementations of type inference and/or if we passed explicit type arguments. Fortunately, most | |
* of the checks here are for edge cases that are unlikely to arise in practice. |
static final NullnessUnspecifiedTypeParameter<@Nullable Object> A2 = | ||
// :: error: jspecify_nullness_mismatch |
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 the really old version of the CF main
uses, the error was apparently on the =
.
For a long while, it is now on the right-hand side of the assignment, which is here on a different line.
As these are tests for a particular tool, I think it's fine to move the expected error.
For the conformance tests, we should look into ensuring such tests are always on one line.
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.
Moving it SGTM.
Putting everything on one line in the future sounds good if we can get away with it.
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.
Nice to see a bunch of spurious errors melt away :)
@@ -43,7 +43,7 @@ interface SuperSuper<T extends @Nullable Object> { | |||
|
|||
void checkNeverNull(Lib<? extends Object> lib); | |||
|
|||
<U> void checkUnspecNull(Lib<@NullnessUnspecified U> lib); | |||
<U extends @Nullable Object> void checkUnspecNull(Lib<@NullnessUnspecified U> lib); |
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 think that
jspecify/samples/ComplexParametric.java
Lines 21 to 25 in 8989d39
* Warning: I have probably gotten some things wrong in adding jspecify_* comments in this file. | |
* (Now, that may be the case for *any* file :) But it is particularly likely in this one.) | |
* Additionally, some checks would probably have different results under slightly different | |
* implementations of type inference and/or if we passed explicit type arguments. Fortunately, most | |
* of the checks here are for edge cases that are unlikely to arise in practice. |
return x; | ||
} | ||
|
||
<T extends @Nullable Object & @Nullable Lib> Object x8(@NullnessUnspecified T x) { | ||
// :: error: jspecify_nullness_mismatch | ||
// :: error: jspecify_nullness_not_enough_information |
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.
// :: error: jspecify_nullness_not_enough_information | |
// :: error: jspecify_nullness_mismatch jspecify_but_expect_warning |
Under our current substitution rules, I think that jspecify_nullness_mismatch
is correct: @NullnessUnspecified T
can currently "add" nullness to the given type but not "remove" nullness from it. So, if T
is a nullable type (as it can be, thanks to the bounds), @NullnessUnspecified T
can be nullable, too.
This may change when we look at #248 again, but for now, it's what our rules say, and it's what other samples are set up for.
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.
(Err, I was assuming above that the checker was currently producing a warning—hence "jspecify_but_expect_warning." But my main point is about why I think "jspecify_nullness_mismatch" is correct. Then we can fill in an "override" like "jspecify_but_expect_warning" or "jspecify_but_expect_nothing" if the checker currently has one of those behaviors and we want to encode it here.)
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've undone this change.
static final NullnessUnspecifiedTypeParameter<@Nullable Object> A2 = | ||
// :: error: jspecify_nullness_mismatch |
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.
Moving it SGTM.
Putting everything on one line in the future sounds good if we can get away with it.
No description provided.