Bug 83600 - [code assist] METHOD_REF proposals have non-standard signatures
Summary: [code assist] METHOD_REF proposals have non-standard signatures
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 84658 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-25 06:56 EST by Tom Hofmann CLA
Modified: 2005-02-14 12:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-01-25 06:56:45 EST
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.
Comment 1 Philipe Mulet CLA 2005-02-03 05:24:56 EST
++ 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.
Comment 2 David Audel CLA 2005-02-03 06:17:40 EST
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.
Comment 3 David Audel CLA 2005-02-03 07:08:38 EST
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>).
Comment 4 David Audel CLA 2005-02-09 09:32:56 EST
*** Bug 84658 has been marked as a duplicate of this bug. ***
Comment 5 David Audel CLA 2005-02-09 09:46:35 EST
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.
Comment 6 Jerome Lanneluc CLA 2005-02-14 12:35:41 EST
Verified in I20050214