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

Updates to better match main-eisop reference checker #505

Merged

Conversation

wmdietl
Copy link
Collaborator

@wmdietl wmdietl commented Apr 11, 2024

No description provided.

Copy link
Collaborator Author

@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.

@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);
Copy link
Collaborator Author

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.

Copy link
Collaborator

@cpovirk cpovirk Apr 12, 2024

Choose a reason for hiding this comment

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

I think that

* 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.
is enough reason not to worry too much about this file in general :)

static final NullnessUnspecifiedTypeParameter<@Nullable Object> A2 =
// :: error: jspecify_nullness_mismatch
Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

@wmdietl wmdietl requested a review from cpovirk April 11, 2024 21:53
Copy link
Collaborator

@cpovirk cpovirk left a 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);
Copy link
Collaborator

@cpovirk cpovirk Apr 12, 2024

Choose a reason for hiding this comment

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

I think that

* 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.
is enough reason not to worry too much about this file in general :)

return x;
}

<T extends @Nullable Object & @Nullable Lib> Object x8(@NullnessUnspecified T x) {
// :: error: jspecify_nullness_mismatch
// :: error: jspecify_nullness_not_enough_information
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// :: 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.

Copy link
Collaborator

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.)

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've undone this change.

static final NullnessUnspecifiedTypeParameter<@Nullable Object> A2 =
// :: error: jspecify_nullness_mismatch
Copy link
Collaborator

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.

@wmdietl wmdietl merged commit 5e5ce85 into samples-google-prototype-eisop Apr 22, 2024
11 checks passed
@wmdietl wmdietl deleted the samples-google-prototype-eisop-fixes branch April 22, 2024 21:15
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.

None yet

2 participants