t-rasmud / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
2 stars 2 forks source link

Polymorphic qualifiers not resolved on type parameter bounds, extends and implements clauses of classes with @HasQualifierParameter #136

Open t-rasmud opened 4 years ago

t-rasmud commented 4 years ago

Consider the following test case:

import org.checkerframework.checker.determinism.qual.NonDet;
import org.checkerframework.checker.determinism.qual.PolyDet;
import org.checkerframework.framework.qual.HasQualifierParameter;

@HasQualifierParameter(NonDet.class)
class PolyClass<T extends @PolyDet("use") Object> {}

public class TestPolySubtyping {
    void test1(@NonDet PolyClass<@NonDet Object> arg) {}
}

Since PolyClass has an implicit qualifier parameter, @PolyDet("use") on the extends clause of T must resolve to @NonDet and the above code must type check. But the determinism checker flags the following error:

./checker/tests/determinism/TestPolySubtyping.java:9: error: [type.argument.type.incompatible] incompatible types in type argument.
    void test1(@NonDet PolyClass<T> arg) {}
                                 ^
  found   : T extends @NonDet Object
  required: @PolyDet("use") Object
smillst commented 4 years ago

We don't support polymorphic qualifiers on class declarations, including in type parameter bounds. Is this issue about adding that support?

t-rasmud commented 4 years ago

I see, Thanks! Currently, the checker doesn't report any warning if polymorphic annotations are written on declarations or type parameters of classes with implicit qualifier parameters. However, I think it will be useful to add support for this feature.