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

main-eisop: Unbounded wildcards default to non-nullable #161

Closed
cpovirk opened this issue Feb 8, 2024 · 1 comment · Fixed by #165
Closed

main-eisop: Unbounded wildcards default to non-nullable #161

cpovirk opened this issue Feb 8, 2024 · 1 comment · Fixed by #165
Assignees

Comments

@cpovirk
Copy link
Collaborator

cpovirk commented Feb 8, 2024

This is at least a contributor to perhaps 500ish [edit: probably even more!] of the 800ish errors that I've seen in testing inside Google so far:

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

@NullMarked
class UnboundedDefaultsToNonNull<E extends @Nullable Object> {
  UnboundedDefaultsToNonNull<?> x() {
    return this;
  }
}
$ ../checker-framework/checker/bin/javac -processorpath $HOME/.m2/repository/org/jspecify/jspecify/0.3.0/jspecify-0.3.0.jar:build/libs/jspecify-reference-checker-0.0.0-SNAPSHOT.jar -processor com.google.jspecify.nullness.NullSpecChecker -AcheckImpl -AassumePure -AsuppressWarnings=contracts.conditional.postcondition.false.methodref,contracts.conditional.postcondition.false.override,contracts.conditional.postcondition.true.methodref,contracts.conditional.postcondition.true.override,purity.methodref,purity.overriding,type.anno.before.decl.anno,type.anno.before.modifier -cp $HOME/.m2/repository/org/jspecify/jspecify/0.3.0/jspecify-0.3.0.jar:build/libs/jspecify-reference-checker-0.0.0-SNAPSHOT.jar UnboundedDefaultsToNonNull.java
UnboundedDefaultsToNonNull.java:7: error: [return.type.incompatible] incompatible types in return.
    return this;
           ^
  type of expression: UnboundedDefaultsToNonNull<E>
  method return type: UnboundedDefaultsToNonNull<? extends Object>
1 error

In @NullMarked code, UnboundedDefaultsToNonNull<?> should be treated like UnboundedDefaultsToNonNull<? extends @Nullable Object>, rather than like UnboundedDefaultsToNonNull<? extends [@NonNull] Object>. This is jspecify/checker-framework#2.

wmdietl added a commit that referenced this issue Feb 26, 2024
@wmdietl wmdietl linked a pull request Feb 28, 2024 that will close this issue
wmdietl added a commit that referenced this issue Apr 10, 2024
@wmdietl
Copy link
Collaborator

wmdietl commented Apr 11, 2024

Fixed by #165.

@wmdietl wmdietl closed this as completed Apr 11, 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