Bug 85491 - [1.5] Compiler rejects autoboxing-calls to overloaded varargs methods as ambiguous
Summary: [1.5] Compiler rejects autoboxing-calls to overloaded varargs methods as ambi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-16 13:17 EST by Markus Keller CLA
Modified: 2005-08-19 14:02 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-02-16 13:17:47 EST
I20050215-2300

The compiler rejects autoboxing-calls to overloaded varargs methods as
ambiguous. Class Works compiles fine with javac, whereas Eclipse thinks that all
calls to take(..) are ambiguous.

class Works {
	void take(char... chars) {}
	void take(Object... objs) {}
	
	void give() {
		take('a');
		take('a', Character.valueOf('x'));
		take(Character.valueOf('x'));
	}
}

In class Ambiguous, both Eclipse and javac think they cannot solve the ambiguity:
class Ambiguous {
	void take(char... chars) {}
	void take(Character... objs) {}
	
	void give() {
		take('a');
		take('a', Character.valueOf('x'));
		take(Character.valueOf('x'));
	}
}
Comment 1 Kent Johnson CLA 2005-03-06 14:22:56 EST
*** Bug 87142 has been marked as a duplicate of this bug. ***
Comment 2 Kent Johnson CLA 2005-03-10 11:32:00 EST
Here is another case:

class X {
	void foo(int... i) {}
	void foo(Number... n) {}
//	void foo(Object... o) {}
	
	void test() {
		foo(1);
		foo(1, new Integer(1));
		foo(new Integer(1));
	}
}

All 3 message sends are ambiguous with javac as they are with Eclipse. Number 
is a superclass of Integer just as Object is.

But when foo(Number...) is replaced with foo(Object...) it works.
Comment 3 Kent Johnson CLA 2005-03-10 16:59:42 EST
Added AutoBoxing test101
Comment 4 Olivier Thomann CLA 2005-03-30 18:55:23 EST
Verified in 20050330-0500
Comment 5 Jason CLA 2005-08-19 14:02:31 EDT
In Eclipse 3.1, we are seeing this behavior again.

The two method signatures:

protected Object getResult( boolean isBlocking, Object... params ) {...}
protected Object getResult( Object... params ) {...}

With the following invocation:

getResult( isBlocking );

is resulting (no pun intended) in the following error while building:

"The method getResult(Object[]) is ambiguous for the type ..."

Compiling code via the command line, works fine.