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

Lenient mode errors for returning nullable values from null-unmarked methods with a type-parameter return type #172

Closed
cpovirk opened this issue Apr 12, 2024 · 5 comments · Fixed by #175

Comments

@cpovirk
Copy link
Collaborator

cpovirk commented Apr 12, 2024

At the current main-eisop (76b33c9) and still with #171:

class Issue172<E> {
  E e() {
    return null;
  }
}
$ ./demo Issue172.java
Issue172.java:3: error: [return.type.incompatible] incompatible types in return.
    return null;
           ^
  type of expression: null?
  method return type: E
1 error

This should be allowed because the return type should be read as E* (i.e., E with unspecified nullness), which permits null in lenient mode.

Since this error comes up only in null-unmarked code, we should be OK with suppressing the small number of times that it occurs. Still, I'm filing it for tracking.

@cpovirk
Copy link
Collaborator Author

cpovirk commented Apr 12, 2024

(76b33c9#diff-ce82a59b06d0d82bfc6d06835d1b06ac15619bc3a71617d32189d041f02ca9c0R921 came to mind because I remembered seeing nullnessOperatorUnspecified, but undoing that change does not help.)

@cpovirk
Copy link
Collaborator Author

cpovirk commented Apr 19, 2024

I've realized that my earlier testing was incomplete. And it turns out that this problem comes up more when I test fully.

On the bright side, my testing with #175 (well, with my variant of it) does appear to eliminate those errors. So we still look to be in good shape.

@cpovirk
Copy link
Collaborator Author

cpovirk commented Apr 19, 2024

Yes, once #171 and #175 have both landed, I think we'll be ready to switch over.

@cpovirk
Copy link
Collaborator Author

cpovirk commented Apr 19, 2024

(Or, come to think of it, I might be able to mostly work around this one if necessary. But I'm not sure, and it would be at least a little work.)

@wmdietl
Copy link
Collaborator

wmdietl commented Apr 22, 2024

Fixed by #175.

@wmdietl wmdietl closed this as completed Apr 22, 2024
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 a pull request may close this issue.

2 participants