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

#738 breaks a handful of our tests #757

Open
cpovirk opened this issue May 2, 2024 · 4 comments
Open

#738 breaks a handful of our tests #757

cpovirk opened this issue May 2, 2024 · 4 comments

Comments

@cpovirk
Copy link

cpovirk commented May 2, 2024

  found   : @NonNull Foo<capture#02 extends @NonNull Foo<capture#02>>
  required: @Nullable Foo<? extends @NonNull Object>

It looks to me like the found type meets the requirements of the required type, so I'm not sure exactly where the problem lies.

I'll try to minimize that in the next couple days so that I can send you an actual repro.

@cpovirk
Copy link
Author

cpovirk commented May 2, 2024

Interestingly, that error arises only(?) in locations that previously had this error, which we had suppressed:

error: [type.invalid.conflicting.annos] invalid type: conflicting annotations [@NonNull, @Nullable] in type "@NonNull @Nullable Foo<capture#02 extends @NonNull @Nullable Foo<capture#02>>"

I think I'm close to a self-contained repro, but I'm posting that little bit for now so that I can close a couple windows I have open about it :)

@cpovirk
Copy link
Author

cpovirk commented May 2, 2024

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

@NullMarked
class Eisop757 {
  @SuppressWarnings("nullness:return.type.incompatible")
  <T> @NonNull T nullCheck(@Nullable T reference) {
    return reference;
  }

  void foo(Foo<? extends Bar<?>> foo) {
    Bar<?> cell = nullCheck(foo.bar());
  }

  interface Foo<T extends Bar<T>> {
    @Nullable T bar();
  }

  interface Bar<T> {}
}
/usr/local/google/home/cpovirk/code/Eisop757.java:13: error: [assignment.type.incompatible] incompatible types in assignment.
    Bar<?> cell = nullCheck(foo.bar());
                           ^
  found   : @NonNull Bar<capture#01 extends @NonNull Bar<capture#01>>
  required: @Nullable Bar<? extends @NonNull Object>
1 error

@cpovirk
Copy link
Author

cpovirk commented May 6, 2024

Interestingly, that error arises only(?) in locations that previously had this error, which we had suppressed:

The old error is gone, at least :) So #738 hasn't actually increased the number of errors, just changed the kind of error that we see, undoing our old suppressions.

@wmdietl
Copy link
Member

wmdietl commented May 22, 2024

@cpovirk Sorry for not commenting on this (since a comment in a document when you filed this).

I cannot reproduce a difference between before #738 and after. I also tried typetools release checker-framework-3.42.0.
I tried your version and the following CF-only version:

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

class Eisop757 {
  @SuppressWarnings("nullness:return.type.incompatible")
  <T extends Object> @NonNull T nullCheck(@Nullable T reference) {
    return reference;
  }

  void foo(Foo<? extends Bar<?>> foo) {
    Bar<?> cell = nullCheck(foo.bar());
  }

  interface Foo<T extends Bar<T>> {
    @Nullable T bar();
  }

  interface Bar<T extends Object> {}
}

Are you using the CF Nullness Checker or the JSpecify reference checker?

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

No branches or pull requests

2 participants