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

Warning for element have annotation Annotatedfor(...) and UnannotatedFor(...) #876

Open
Ao-senXiong opened this issue Aug 22, 2024 · 1 comment

Comments

@Ao-senXiong
Copy link
Member

Issue a warning if one element(package, class, method ...) have both annotation with one of the value matches.

@wmdietl
Copy link
Member

wmdietl commented Aug 30, 2024

Let's widen this issue to cover all defaulting annotations.
For example, this does not produce a warning:

import org.checkerframework.framework.qual.DefaultQualifier;
import org.checkerframework.framework.qual.TypeUseLocation;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;

@DefaultQualifier(value = NonNull.class, locations = TypeUseLocation.IMPLICIT_UPPER_BOUND)
@DefaultQualifier(value = Nullable.class, locations = TypeUseLocation.IMPLICIT_UPPER_BOUND)
@DefaultQualifier(value = Nullable.class, locations = TypeUseLocation.IMPLICIT_UPPER_BOUND)
class Demo<T> {
  void foo(T p) {
    p.toString(); // OK?
  }
}

Nullable is listed twice with the same locations, which should produce a warning.

The same location is used with different qualifiers from the same hierarchy, which should also be a warning.
In my tests NonNull always won and the .toString never produced an error, even with different orders of the annotations.

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