Please, fix this embarrassing generics IDEA bug

The code here compiles just fine, but IDEA marks the call to myMethod with a red underline.  The issue is that IDEA's generics support doesn't recognise that the type parameter on Dummy here is compatible with the method signature because of the constraints on the class.  ? here means 'T extends Number & Comparable< T >'.  Please fix this bug!  It's in the issue tracker already as IDEA-55003.  We use this in several places in our code and it's really annoying to see red marks.

public class IDEAGenericsFail {

    public static void main(String[] args) {
        IDEAGenericsFail fail = new IDEAGenericsFail();
        
        Dummy d = new Dummy();

        fail.myMethod(d);
    }

    public > Dummy myMethod(Dummy dummy) {
        return null;
    }

    public static class Dummy> {
    }
}
1 comment

I will try again with the code:

public class IDEAGenericsFail {

    public static void main(String[] args) {
        IDEAGenericsFail fail = new IDEAGenericsFail();

        Dummy<?> d = new Dummy<Integer>();

        fail.myMethod(d);
    }

    public <T extends Number & Comparable<T>> Dummy<T> myMethod(Dummy<T> dummy) {
        return null;
    }

    public static class Dummy<T extends Number & Comparable<T>> {
    }
}

0

Please sign in to leave a comment.