typetools / checker-framework

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

Unexpected compilation error Enum<Enum<... #1250

Open justmin opened 7 years ago

justmin commented 7 years ago
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Set;
import java.util.TreeSet;

public class Test<K extends Enum<K>, A extends Annotation> {

    public static <K extends Enum<K>, A extends Annotation> Set<String> foo(Test<K, A> test, Class<?> cl){
        Set<String> result = new TreeSet<>();
        for (Field field : cl.getFields()) {
            result.addAll(foo(test, field.getType()));
        }
        return result;
    }
}

Produce error Error:(13, 30) java: [type.argument.type.incompatible] incompatible types in type argument. found : Enum<K extends Enum> required: Enum<Enum<K extends Enum>>

CF 2.1.0

justmin commented 7 years ago

@SuppressWarnings("nullness") doesn't help

wmdietl commented 7 years ago

Can still reproduce with CF 2.1.10. To suppress the errors, use @SuppressWarnings({"keyfor", "nullness"})