Good generics code marked red


The following code compiles fine with javac (and IDEA makes it fine), but the call to myMethod is marked with a red squiggle.

javac -Xlint also produces no warnings.

public class Scratch {
    public void shouldCompile() {
        Sample<?> sample = (Sample<?>) new Sample();

        // The below line shows a red underline in IDEA 9.0.2

    public static class Sample<T extends Number & Comparable<T>> {

    protected <T extends Number & Comparable<T>> Sample<T> myMethod(Sample<T> sample) {
        return sample;

1 comment
Comment actions Permalink

Hi Ben,

Looks like a bug. Please submit corresponding ticket to IDEA tracker.


Please sign in to leave a comment.