Bug 129056 - compiler fails to detect ambiguous method when autoboxing and implementing an interface
Summary: compiler fails to detect ambiguous method when autoboxing and implementing an...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 16:14 EST by Ben Arnold CLA
Modified: 2006-03-27 10:27 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Arnold CLA 2006-02-22 16:14:45 EST
In the code below, Eclipse marks the call to ambiguity.meth as a compiler error "ambiguous", but the call to noAmbiguity.meth generates no compiler error, when it should generate exactly the same error.

The only difference between Ambiguity and NoAmbiguity is that one of the ambiguous methods in NoAmbiguity implements an interface.

The correct behaviour (according to Java Language Spec and javac) is for both calls to generate a compiler error.


public class Bug {

	public static class Ambiguity {
		public void meth(int arg1, int arg2) {
		}

		public void meth(Number arg1, Number arg2) {
		}
	}

	public interface Interface {
		public void meth(Number arg1, Number arg2);
	}

	public static class NoAmbiguity implements Interface {
		public void meth(int arg1, int arg2) {
		}

		public void meth(Number arg1, Number arg2) {
		}
	}

	public static void main(String[] args) {

		NoAmbiguity noAmbiguity = new NoAmbiguity();
		noAmbiguity.meth(new Integer(1), 2);

		Ambiguity ambiguity = new Ambiguity();
		ambiguity.meth(new Integer(1), 2);
	}
}
Comment 1 Kent Johnson CLA 2006-03-20 14:56:57 EST
Added AmbiguousMethod test007
Comment 2 Frederic Fusier CLA 2006-03-27 10:27:43 EST
Verified for 3.2 M6 using warm-up build I20060327-0010.