Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] How much detail should be surfaced in compiler error message ?

As described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=106514

Our error message for an invalid generic method invocation is a bit hard to
read; partially due to a bug in error reporting:

In 3.1.0 we printed:

Bound mismatch: The generic method isGreater(T, T) of type Hover is not
applicable for the arguments (Number&Comparable<?>, Number&Comparable<?>)
since the type Number&Comparable<?> is not a valid substitute for the
bounded parameter <T extends Comparable<T>>

It should actually better read (see invocation arguments part):

Bound mismatch: The generic method isGreater(T, T) of type Hover is not
applicable for the arguments (Integer, Double). The inferred type
Number&Comparable<?> is not a valid substitute for the bounded parameter <T

extends Comparable<T>>

Now it reveals the proper invocation arguments, and the fact it is failing
due to a bound check issue for a generic method type parameter. Would
people rather not see these details, and prefer a simplified message:

The method isGreater(T, T) of type Hover is not applicable for the
arguments (Integer, Double).

?

(please answer in bug report directly)



=============

class Hover {
             <T extends Comparable<T>> boolean isGreater(T t1, T t2) {
                         return t1.compareTo(t2) > 0 ? true : false;
             }

             void method(Integer i, Double d) {
                         isGreater(i, d);
             }
}



Back to the top