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

False positive with captured wildcards #6663

Open
smillst opened this issue Jun 7, 2024 · 0 comments
Open

False positive with captured wildcards #6663

smillst opened this issue Jun 7, 2024 · 0 comments

Comments

@smillst
Copy link
Member

smillst commented Jun 7, 2024

Several checkers produce a false positive on the following code.

public class Buggy {

  <A extends FooClass<A>> void use(FooClass<A> fooClass1, FooClass<A> fooClass2) {
    fooClass1.getThenStore().merge(fooClass2.getThenStore());

  }

  interface FooInterface<V extends FooInterface<V>> {}

  interface BarInterface<S extends BarInterface<S>> {}

  static abstract class BarClass<V extends FooClass<V>, S extends BarClass<V, S>> implements
      BarInterface<S> {

    public <S> void merge(S thenStore) {
    }
  }

  static class FooClass<V extends FooClass<V>> implements FooInterface<V> {

    FooInterface<?> a;

    void addStores(FooInterface<?> a) {
      this.a = a;
    }

    @SuppressWarnings("unchecked")
    public <S extends BarClass<V, S>> S getThenStore() {
      return (S) a;
    }
  }
}

/testcases/src/Buggy.java:4: error: [argument] incompatible argument for parameter thenStore of BarClass.merge.
    fooClass1.getThenStore().merge(fooClass2.getThenStore());
                                                         ^
  found   : @UnknownInterned BarClass<A[ extends @UnknownInterned FooClass<A[ extends @UnknownInterned FooClass<A> super @InternedDistinct Void]> super @InternedDistinct Void], capture#01[ extends @UnknownInterned BarClass<A[ extends @UnknownInterned FooClass<A[ extends @UnknownInterned FooClass<A> super @InternedDistinct Void]> super @InternedDistinct Void], capture#01> super @InternedDistinct Void]>
  required: capture#02[ extends @UnknownInterned Object super @InternedDistinct Void]
1 error
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

1 participant