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

assignment.type.incompatible when using <? extends E> where <E extends @Nullable T> #3027

Open
cpovirk opened this issue Jan 2, 2020 · 2 comments

Comments

@cpovirk
Copy link
Contributor

cpovirk commented Jan 2, 2020

This is minimized from the real code (though that link doesn't include the nullness annotations, nor the additional type parameter that causes the problem).

$ cat Caller.java
import org.checkerframework.checker.nullness.qual.Nullable;

class Caller {
  <T, E extends @Nullable T> void foo(Multiset<? extends E> multiset) {
    Entry<? extends E> entry = multiset.someEntry();
  }
}

interface Multiset<E> {
  Entry<E> someEntry();
}

interface Entry<E> {}
$ checker/bin/javac -processor org.checkerframework.checker.nullness.NullnessChecker Caller.java
Caller.java:5: error: [assignment.type.incompatible] incompatible types in assignment.
    Entry<? extends E> entry = multiset.someEntry();
                                                 ^
  found   : @Initialized @NonNull Entry<?[ extends E[ extends T[ extends @Initialized @Nullable Object super @Initialized @Nullable Void] super @Initialized @NonNull Void] super @Initialized @NonNull Void]>
  required: @UnknownInitialization @Nullable Entry<?[ extends E[ extends T[ extends @Initialized @Nullable Object super @Initialized @Nullable Void] super @Initialized @NonNull Void] super @Initialized @NonNull Void]>
1 error

I believe this should be legal: The "found" and "required" are identical if you strip off the first two annotations, and for those annotations, the "found" looks to be a subtype of the "required."

@cpovirk
Copy link
Contributor Author

cpovirk commented Jan 2, 2020

Sorry, forgot attachments for source file and -version -verbose -AprintAllQualifiers output.

@smillst
Copy link
Member

smillst commented Jan 3, 2020

I agree this is a bug. I've traced it to a problem in org.checkerframework.framework.type.DefaultTypeHierarchy#isContainedWildcard, but I'm not sure yet how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants