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

Warn if @HasQualifierParameter is written on a supertype but not on a subtype #6780

Closed
mernst opened this issue Sep 4, 2024 · 1 comment
Closed

Comments

@mernst
Copy link
Member

mernst commented Sep 4, 2024

The manual says:

If a subclass extends a @HasQualifierParameter class (or implements a @HasQualifierParameter interface), then the subclass must also be marked @HasQualifierParameter.

It is difficult to diagnose the problem when @HasQualifierParameter is forgotten on a subtype.
Therefore, the Checker Framework should check for this condition, and issue a warning.

@smillst
Copy link
Member

smillst commented Sep 5, 2024

@HasQualifierParameter is marked @Inherited, so you shouldn't have to write it on a subtype. Do you have an example where this isn't working. Here's an example that produces errors because MyBuffer has a qualifier parameter:

import org.checkerframework.checker.tainting.qual.Tainted;
import org.checkerframework.framework.qual.HasQualifierParameter;
import org.checkerframework.checker.tainting.qual.Untainted;

class MyBuffer extends Buffer {

  public void method1(@Tainted MyBuffer b1, @Untainted MyBuffer b2) {
    b1 = b2;  // error
  }

  public void method2(@Tainted Buffer b1, @Untainted Buffer b2) {
    b1 = b2;  // error
  }
}

@HasQualifierParameter(Tainted.class)
public class Buffer {}

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