Bug 129056

Summary: compiler fails to detect ambiguous method when autoboxing and implementing an interface
Product: [Eclipse Project] JDT Reporter: Ben Arnold <bena>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1.1   
Target Milestone: 3.2 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.