Community
Participate
Working Groups
I20050118 / jdt-core HEAD of 20050125 When collecting CompletionProposals in the following situations, the returned proposals of type METHOD_REF have non-standard signatures (see also bug 83383). Examples (always invoke content assist at the caret |) ----- double bound characters ------ void tryLists(List<? extends Number> ext, List<? super Number> sup, List<?> star, List<Number> conc) { Number n= null; Integer i= null; Object o= null; ext.addAll| } -> received: (ILjava.util.Collection<++Ljava.lang.Number;>;)Z -> note the double ++ ----- double bound characters 2 ------ void tryLists(List<? extends Number> ext, List<? super Number> sup, List<?> star, List<Number> conc) { Number n= null; Integer i= null; Object o= null; star.addAll| } -> received: (ILjava.util.Collection<+*>;)Z -> note the double erroneous + ----- bounded parameters ------ void tryLists(List<? extends Number> ext, List<? super Number> sup, List<?> star, List<Number> conc) { Number n= null; Integer i= null; Object o= null; sup.add| } -> received for add(int, Number): (I-Ljava.lang.Number;)V While it is intuitive, this signature is not valid when fed to Signature.getParameterCount, because of the bounded type. -- I currently uncook the bounds: '(I-Ljava.lang.Number;)V' -> '(ILjava.lang.Number;)V' '(I+Ljava.lang.Number;)V' -> '(I+TNULL;)V' (null type) and vice-versa for return types. I would expect to receive either : - signatures that are already treated in the way outlined above - a special signature kind which may contain such bounds. In that case, I would expect that the Signature class can deal with them.
++ and +* definitely look wrong. However, first level wildcards are possible in method invocations (not in method declarations), due to substitution of variables. Signature should honour these.
The signature is computed from a binding and the binding seems incorrect: 'boolean addAll(Collection<? extends ? extends java.lang.Number>)' for the first test case. This method binding come from ParameterizedTypeBinding#avaibleMethods() and the type binding seems correct: 'public interface List<? extends java.lang.Number>'. The problem could be inside substitution when building parameterized method.
My previous comment is wrong. 'boolean addAll(Collection<? extends ? extends java.lang.Number>)' is a valid binding. The receiver type is List<? extends java.lang.Number>, so the type argument E of List<E> is '? extends java.lang.Number'. The generic method is addAll(Collection<? extends E>), so the parameterized method is addAll(Collection<? extends ? extends Number>).
*** Bug 84658 has been marked as a duplicate of this bug. ***
signature with multiple levels of wildcards can exist after subsitution of variable. Fixed and test updated SignatureTests#testGetParamaterCount() signature with ++, +-, +* are now considered as valid signature by Signature.
Verified in I20050214